mwifiex: don't leak 'chan_stats' on reset
authorBrian Norris <briannorris@chromium.org>
Fri, 14 Apr 2017 21:51:20 +0000 (14:51 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 20 Apr 2017 07:21:53 +0000 (10:21 +0300)
'chan_stats' is (re)allocated in _mwifiex_fw_dpc() ->
mwifiex_init_channel_scan_gap(), which is called whenever the device is
initialized -- at probe or at reset.

But we only free it in we completely unregister the adapter, meaning we
leak a copy of it during every reset.

Let's free it in the shutdown / removal paths instead (and in the
error-handling path), to avoid the leak.

Ideally, we can eventually unify much of mwifiex_shutdown_sw() and
mwifiex_remove_card() (way too much copy-and-paste) to reduce the burden
on bugfixes like this. But that's work for tomorrow.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/main.c

index fdeb0bbb884c563bdfe84bc0c8ae1808627beaf3..739d654bc9a6140b9db2c103b2678a1685f9a451 100644 (file)
@@ -149,7 +149,6 @@ static int mwifiex_unregister(struct mwifiex_adapter *adapter)
 
        kfree(adapter->regd);
 
-       vfree(adapter->chan_stats);
        kfree(adapter);
        return 0;
 }
@@ -633,6 +632,7 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context)
        goto done;
 
 err_add_intf:
+       vfree(adapter->chan_stats);
        wiphy_unregister(adapter->wiphy);
        wiphy_free(adapter->wiphy);
 err_init_fw:
@@ -1417,6 +1417,7 @@ mwifiex_shutdown_sw(struct mwifiex_adapter *adapter)
                        mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
                rtnl_unlock();
        }
+       vfree(adapter->chan_stats);
 
        mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
 exit_return:
@@ -1726,6 +1727,7 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter)
                        mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
                rtnl_unlock();
        }
+       vfree(adapter->chan_stats);
 
        wiphy_unregister(adapter->wiphy);
        wiphy_free(adapter->wiphy);