Browse Source

qcacld-3.0: Pass double pointer to hdd_softap_deregister_sta

The function hdd_softap_deregister_sta takes the sta_info as the
argument and calls hdd_sta_info_detach. In hdd_sta_info_detach, the
memory assigned to the sta_info is being freed. For this memory to be
properly freed and set to NULL, the actual memory location must be
passed to the function; which is currently not happening.

Pass the actual memory location by reference using a double pointer so
that the memory cleanup is proper.

Change-Id: If0f846957df0378ea7a13b76bdf9c6ef562ed90e
CRs-Fixed: 2627296
Sourav Mohapatra 5 years ago
parent
commit
bfa435bccc

+ 3 - 3
core/hdd/inc/wlan_hdd_softap_tx_rx.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -111,12 +111,12 @@ QDF_STATUS hdd_softap_rx_packet_cbk(void *adapter_context, qdf_nbuf_t rx_buf);
 /**
  * hdd_softap_deregister_sta() - Deregister a STA with the Data Path
  * @adapter: pointer to adapter context
- * @sta_info: pointer to HDD station info structure
+ * @sta_info: double pointer to HDD station info structure
  *
  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
  */
 QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
-				     struct hdd_station_info *sta_info);
+				     struct hdd_station_info **sta_info);
 
 /**
  * hdd_softap_register_sta() - Register a SoftAP STA

+ 2 - 2
core/hdd/src/wlan_hdd_hostapd.c

@@ -2361,7 +2361,7 @@ QDF_STATUS hdd_hostapd_sap_event_cb(struct sap_event *sap_event,
 					  WMA_DHCP_STOP_IND);
 		stainfo->dhcp_nego_status = DHCP_NEGO_STOP;
 
-		hdd_softap_deregister_sta(adapter, stainfo);
+		hdd_softap_deregister_sta(adapter, &stainfo);
 
 		ap_ctx->ap_active = false;
 
@@ -6744,7 +6744,7 @@ void hdd_sap_indicate_disconnect_for_sta(struct hdd_adapter *adapter)
 			  QDF_MAC_ADDR_ARRAY(sta_info->sta_mac.bytes));
 
 		if (qdf_is_macaddr_broadcast(&sta_info->sta_mac)) {
-			hdd_softap_deregister_sta(adapter, sta_info);
+			hdd_softap_deregister_sta(adapter, &sta_info);
 			continue;
 		}
 

+ 9 - 9
core/hdd/src/wlan_hdd_softap_tx_rx.c

@@ -941,11 +941,12 @@ QDF_STATUS hdd_softap_rx_packet_cbk(void *adapter_context, qdf_nbuf_t rx_buf)
 }
 
 QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
-				     struct hdd_station_info *sta_info)
+				     struct hdd_station_info **sta_info)
 {
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	struct hdd_context *hdd_ctx;
 	struct qdf_mac_addr *mac_addr;
+	struct hdd_station_info *sta = *sta_info;
 
 	if (!adapter) {
 		hdd_err("NULL adapter");
@@ -957,7 +958,7 @@ QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	if (!sta_info) {
+	if (!sta) {
 		hdd_err("Invalid station");
 		return QDF_STATUS_E_INVAL;
 	}
@@ -973,10 +974,10 @@ QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
 	 * If the address is a broadcast address then the CDP layers expects
 	 * the self mac address of the adapter.
 	 */
-	if (QDF_IS_ADDR_BROADCAST(sta_info->sta_mac.bytes))
+	if (QDF_IS_ADDR_BROADCAST(sta->sta_mac.bytes))
 		mac_addr = &adapter->mac_addr;
 	else
-		mac_addr = &sta_info->sta_mac;
+		mac_addr = &sta->sta_mac;
 
 	/* Clear station in TL and then update HDD data
 	 * structures. This helps to block RX frames from other
@@ -984,7 +985,7 @@ QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
 	 */
 
 	hdd_debug("Deregistering sta: " QDF_MAC_ADDR_STR,
-		  QDF_MAC_ADDR_ARRAY(sta_info->sta_mac.bytes));
+		  QDF_MAC_ADDR_ARRAY(sta->sta_mac.bytes));
 
 	qdf_status = cdp_clear_peer(
 			cds_get_context(QDF_MODULE_ID_SOC),
@@ -1005,7 +1006,7 @@ QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
 				      mac_addr->bytes) != QDF_STATUS_SUCCESS)
 			hdd_debug("WLAN_CLIENT_DISCONNECT event failed");
 	}
-	hdd_sta_info_detach(&adapter->sta_info_list, &sta_info);
+	hdd_sta_info_detach(&adapter->sta_info_list, &sta);
 
 	ucfg_mlme_update_oce_flags(hdd_ctx->pdev);
 
@@ -1037,7 +1038,7 @@ QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter,
 	if (sta_info) {
 		hdd_debug("clean up old entry for STA MAC " QDF_MAC_ADDR_STR,
 			  QDF_MAC_ADDR_ARRAY(sta_mac->bytes));
-		hdd_softap_deregister_sta(adapter, sta_info);
+		hdd_softap_deregister_sta(adapter, &sta_info);
 	}
 
 	/*
@@ -1192,8 +1193,7 @@ QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter)
 
 	hdd_for_each_station_safe(adapter->sta_info_list, sta_info,
 				  index, tmp) {
-		status = hdd_softap_deregister_sta(adapter,
-						   sta_info);
+		status = hdd_softap_deregister_sta(adapter, &sta_info);
 
 		if (QDF_IS_STATUS_ERROR(status) && sta_info)
 			hdd_debug("Deregistering STA " QDF_MAC_ADDR_STR