Ver código fonte

qcacld-3.0: free the memory for ch_list while unloading the driver

qcacld-2.0 to qcacld-3.0 propagation

If unloading the driver at the time __wlan_hdd_cfg80211_stop_ap is
called, free the memory allocated for ch_list before returing
from the __wlan_hdd_cfg80211_stop_ap. Otherwise it will result in
memory leak.

Change-Id: I16ab508f74068f7ca1452c97c6105a1ae6e38ef0
CRs-Fixed: 971886
Ganesh Kondabattini 8 anos atrás
pai
commit
ff05066870
1 arquivos alterados com 18 adições e 5 exclusões
  1. 18 5
      core/hdd/src/wlan_hdd_hostapd.c

+ 18 - 5
core/hdd/src/wlan_hdd_hostapd.c

@@ -8126,11 +8126,6 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
 			 TRACE_CODE_HDD_CFG80211_STOP_AP,
 			 pAdapter->sessionId, pAdapter->device_mode));
 
-	pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
-	ret = wlan_hdd_validate_context(pHddCtx);
-	if (0 != ret)
-		return ret;
-
 	if (!(pAdapter->device_mode == QDF_SAP_MODE ||
 	      pAdapter->device_mode == QDF_P2P_GO_MODE)) {
 		return -EOPNOTSUPP;
@@ -8140,6 +8135,24 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
 		hdd_device_mode_to_string(pAdapter->device_mode),
 		pAdapter->device_mode);
 
+	pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
+	ret = wlan_hdd_validate_context(pHddCtx);
+	if (0 != ret) {
+		if (cds_is_driver_unloading()) {
+			/*
+			 * Unloading the driver so free the memory for ch_list,
+			 * otherwise it will result in memory leak
+			 */
+			if (pAdapter->sessionCtx.ap.sapConfig.acs_cfg.ch_list) {
+				qdf_mem_free(pAdapter->sessionCtx.ap.sapConfig.
+					acs_cfg.ch_list);
+				pAdapter->sessionCtx.ap.sapConfig.acs_cfg.
+					ch_list = NULL;
+			}
+		}
+		return ret;
+	}
+
 	status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
 	while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
 		staAdapter = pAdapterNode->pAdapter;