wcn36xx_platform_get_resources() acquires two SMEM state handles, but the probe error path only unmaps the MMIO resources when ieee80211_register_hw() fails. This leaks both state references. Introduce wcn36xx_platform_release_resources() to release the state handles and MMIO mappings together, and use it in the probe error path and removal. Fixes: f303a9311065 ("wcn36xx: Transition driver to SMD client") Signed-off-by: Wanhui Fu --- Changes in v2: - Introduce wcn36xx_platform_release_resources() and use it in probe error handling and removal, as suggested by Loic. Thanks, Loic! - Update the commit message. --- drivers/net/wireless/ath/wcn36xx/main.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index fa3e86f442a6..9d0408a0b25b 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1561,6 +1561,14 @@ put_enable_handle: return ret; } +static void wcn36xx_platform_release_resources(struct wcn36xx *wcn) +{ + iounmap(wcn->dxe_base); + iounmap(wcn->ccu_base); + qcom_smem_state_put(wcn->tx_rings_empty_state); + qcom_smem_state_put(wcn->tx_enable_state); +} + static int wcn36xx_probe(struct platform_device *pdev) { struct ieee80211_hw *hw; @@ -1634,13 +1642,12 @@ static int wcn36xx_probe(struct platform_device *pdev) wcn36xx_init_ieee80211(wcn); ret = ieee80211_register_hw(wcn->hw); if (ret) - goto out_unmap; + goto out_free_res; return 0; -out_unmap: - iounmap(wcn->ccu_base); - iounmap(wcn->dxe_base); +out_free_res: + wcn36xx_platform_release_resources(wcn); out_destroy_ept: rpmsg_destroy_ept(wcn->smd_channel); out_wq: @@ -1659,14 +1666,10 @@ static void wcn36xx_remove(struct platform_device *pdev) ieee80211_unregister_hw(hw); - qcom_smem_state_put(wcn->tx_enable_state); - qcom_smem_state_put(wcn->tx_rings_empty_state); + wcn36xx_platform_release_resources(wcn); rpmsg_destroy_ept(wcn->smd_channel); - iounmap(wcn->dxe_base); - iounmap(wcn->ccu_base); - __skb_queue_purge(&wcn->amsdu); mutex_destroy(&wcn->hal_mutex); -- 2.25.1