Bläddra i källkod

qcacmn: Avoid mem leak when create regulatory object

When x_psoc_create_handle return failed,  need free all resources
before return, x_psoc_destroy_handler has no chance to be called
any more.

Change-Id: I63fd3743dd4ef4c9cc35c9ae8464c2b728447818
CRs-Fixed: 2353795
Jianmin Zhu 6 år sedan
förälder
incheckning
74c34ff6b0
1 ändrade filer med 12 tillägg och 2 borttagningar
  1. 12 2
      umac/regulatory/core/src/reg_services.c

+ 12 - 2
umac/regulatory/core/src/reg_services.c

@@ -3319,6 +3319,12 @@ QDF_STATUS wlan_regulatory_psoc_obj_created_notification(
 	status = wlan_objmgr_psoc_component_obj_attach(psoc,
 			WLAN_UMAC_COMP_REGULATORY, soc_reg_obj,
 			QDF_STATUS_SUCCESS);
+	if (QDF_IS_STATUS_ERROR(status)) {
+		qdf_spinlock_destroy(&soc_reg_obj->cbk_list_lock);
+		qdf_mem_free(soc_reg_obj);
+		reg_err("Obj attach failed");
+		return status;
+	}
 
 	reg_debug("reg psoc obj created with status %d", status);
 
@@ -3741,8 +3747,12 @@ QDF_STATUS wlan_regulatory_pdev_obj_created_notification(
 						     WLAN_UMAC_COMP_REGULATORY,
 						     pdev_priv_obj,
 						     QDF_STATUS_SUCCESS);
-	if (QDF_IS_STATUS_SUCCESS(status) &&
-	    !psoc_priv_obj->is_11d_offloaded)
+	if (QDF_IS_STATUS_ERROR(status)) {
+		reg_err("Obj attach failed");
+		qdf_mem_free(pdev_priv_obj);
+		return status;
+	}
+	if (!psoc_priv_obj->is_11d_offloaded)
 		reg_11d_host_scan_init(parent_psoc);
 
 	reg_debug("reg pdev obj created with status %d", status);