qcacmn: Fix memleak during wifi unload
The soc common cleanup should be called from
pdev_deinit path to prevent leak of m/r allocated
for spinlocks and Tx descriptors.
Change-Id: Ie8ad3d164ab07f37f8143d1fe147e5cbabbb4991
diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c
index f1bf1d8..17982e3 100644
--- a/dp/wifi3.0/dp_main.c
+++ b/dp/wifi3.0/dp_main.c
@@ -3014,8 +3014,6 @@
*/
static void dp_soc_cmn_cleanup(struct dp_soc *soc)
{
- dp_tx_soc_detach(soc);
-
qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock);
dp_reo_cmdlist_destroy(soc);
@@ -3870,6 +3868,11 @@
dp_cal_client_detach(&pdev->cal_client_ctx);
soc->pdev_count--;
+
+ /* only do soc common cleanup when last pdev do detach */
+ if (!(soc->pdev_count))
+ dp_soc_cmn_cleanup(soc);
+
wlan_cfg_pdev_detach(pdev->wlan_cfg_ctx);
if (pdev->invalid_peer)
qdf_mem_free(pdev->invalid_peer);
@@ -3971,11 +3974,6 @@
dp_pdev_deinit(txrx_pdev, force);
dp_pdev_detach(txrx_pdev, force);
}
-
- /* only do soc common cleanup when last pdev do detach */
- if (!(soc->pdev_count))
- dp_soc_cmn_cleanup(soc);
-
}
/*
@@ -4152,6 +4150,8 @@
/* Common rings */
dp_srng_cleanup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0);
+ dp_tx_soc_detach(soc);
+
/* Tx data rings */
if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
for (i = 0; i < soc->num_tcl_data_rings; i++) {