From f77acaf949ca8f1c6543acd27d486caf11f249fe Mon Sep 17 00:00:00 2001 From: Rakesh Pillai Date: Tue, 14 Apr 2020 18:25:53 +0530 Subject: [PATCH] qcacmn: Fix memory leak in case of pdev attach failure The cleanup done in case of pdev attach failure does not deinitialize the IPA tx and rx buffers. Also the tx descriptors are not freed in this cleanup path. Due to this, the tx descriptors and IPA tx/rx buffers memory is neither freed not unmapped. Fix this pdev attach failure cleanup path to avoid memory leaks. Change-Id: I570e3618f0f48f56749466fce5bcba5a4ef1c161 CRs-Fixed: 2663036 --- dp/wifi3.0/dp_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index 0cf622cc866a..7628289835b7 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -3297,8 +3297,6 @@ static void dp_soc_cmn_cleanup(struct dp_soc *soc) } qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock); - - dp_reo_cmdlist_destroy(soc); qdf_spinlock_destroy(&soc->rx.reo_cmd_lock); } @@ -4012,8 +4010,10 @@ wdi_attach_fail: fail2: dp_rx_pdev_detach(pdev); + dp_ipa_uc_detach(soc, pdev); fail1: + soc->pdev_count--; if (pdev->invalid_peer) qdf_mem_free(pdev->invalid_peer); @@ -4323,7 +4323,7 @@ static void dp_pdev_deinit(struct cdp_pdev *txrx_pdev, int force) /* only do soc common cleanup when last pdev do detach */ if (!(soc->pdev_count)) - dp_soc_cmn_cleanup(soc); + dp_reo_cmdlist_destroy(soc); wlan_cfg_pdev_detach(pdev->wlan_cfg_ctx); if (pdev->invalid_peer) @@ -4432,6 +4432,10 @@ static void dp_pdev_detach(struct cdp_pdev *txrx_pdev, int force) dp_rx_desc_pool_free(soc, rx_desc_pool); } + /* only do soc common cleanup when last pdev do detach */ + if (!(soc->pdev_count)) + dp_soc_cmn_cleanup(soc); + soc->pdev_list[pdev->pdev_id] = NULL; wlan_minidump_remove(pdev); qdf_mem_free(pdev);