Explorar el Código

qcacld-3.0: Fix psoc ref and memory leaks in mac_open

psoc ref count and mac_context memory is leaked in failure cases
of mac_open API.

Fix the psoc ref count and memory leaks in failure cases.

Change-Id: I39eaa7bef5e5c50b9b1a8833bec5e6da8cdf0d72
CRs-Fixed: 2302187
Vignesh Viswanathan hace 6 años
padre
commit
6b89ab57b5
Se han modificado 1 ficheros con 9 adiciones y 4 borrados
  1. 9 4
      core/mac/src/sys/legacy/src/system/src/mac_init_api.c

+ 9 - 4
core/mac/src/sys/legacy/src/system/src/mac_init_api.c

@@ -144,7 +144,8 @@ QDF_STATUS mac_open(struct wlan_objmgr_psoc *psoc, tHalHandle *pHalHandle,
 	mlme_obj = mlme_get_psoc_obj(psoc);
 	if (!mlme_obj) {
 		pe_err("Failed to get MLME Obj");
-		return QDF_STATUS_E_FAILURE;
+		status = QDF_STATUS_E_FAILURE;
+		goto fail;
 	}
 	p_mac->mlme_cfg = &mlme_obj->cfg;
 
@@ -159,8 +160,8 @@ QDF_STATUS mac_open(struct wlan_objmgr_psoc *psoc, tHalHandle *pHalHandle,
 
 		/* Call routine to initialize CFG data structures */
 		if (QDF_STATUS_SUCCESS != cfg_init(p_mac)) {
-			mac_free_context_buffer();
-			return QDF_STATUS_E_FAILURE;
+			status = QDF_STATUS_E_FAILURE;
+			goto fail;
 		}
 
 		sys_init_globals(p_mac);
@@ -174,10 +175,14 @@ QDF_STATUS mac_open(struct wlan_objmgr_psoc *psoc, tHalHandle *pHalHandle,
 	status =  pe_open(p_mac, cds_cfg);
 	if (QDF_STATUS_SUCCESS != status) {
 		pe_err("pe_open() failure");
-		mac_free_context_buffer();
 		cfg_de_init(p_mac);
+		goto fail;
 	}
 
+	return status;
+fail:
+	wlan_objmgr_psoc_release_ref(psoc, WLAN_LEGACY_MAC_ID);
+	mac_free_context_buffer();
 	return status;
 }