rtlwifi: rtl_pci: Fix memory leak when hardware init fails
authorLarry Finger <Larry.Finger@lwfinger.net>
Mon, 26 Aug 2019 22:03:44 +0000 (17:03 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 3 Sep 2019 13:30:04 +0000 (16:30 +0300)
If the call to hw_init() fails for any of the drivers, the driver will
leak memory that was allocated in BT coexistence setup. Technically, each
of the drivers should have done this free; however placing it in rtl_pci
fixes all the drivers with only a single patch.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtlwifi/pci.c

index 7d96fe5f1a44b060da33c57e761b652196a47b6c..6087ec7a90a6e6ad5d2ac1921beadd243780f866 100644 (file)
@@ -1793,6 +1793,8 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
        if (err) {
                RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
                         "Failed to config hardware!\n");
+               kfree(rtlpriv->btcoexist.btc_context);
+               kfree(rtlpriv->btcoexist.wifi_only_context);
                return err;
        }
        rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,