Skip to contentSkip to conversation

Patch "mwifiex: don't leak 'chan_stats' on reset" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Mar 22, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mwifiex: don't leak 'chan_stats' on reset

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mwifiex-don-t-leak-chan_stats-on-reset.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Thu Mar 22 14:40:23 CET 2018

From: Brian Norris <[email protected]>
Date: Fri, 14 Apr 2017 14:51:20 -0700
Subject: mwifiex: don't leak 'chan_stats' on reset

From: Brian Norris <[email protected]>

[ Upstream commit fb9e67bee3ab7111513130c516ffe378d885c0d0 ]

'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.

---
 drivers/net/wireless/marvell/mwifiex/main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/marvell/mwifiex/main.c +3 -1
@@ -146,7 +146,6 @@ static int mwifiex_unregister(struct mwi
 
 	kfree(adapter->regd);
 
-	vfree(adapter->chan_stats);
 	kfree(adapter);
 	return 0;
 }
@@ -636,6 +635,7 @@ static void mwifiex_fw_dpc(const struct
 	goto done;
 
 err_add_intf:
+	vfree(adapter->chan_stats);
 	wiphy_unregister(adapter->wiphy);
 	wiphy_free(adapter->wiphy);
 err_init_fw:
@@ -1429,6 +1429,7 @@ mwifiex_shutdown_sw(struct mwifiex_adapt
 			mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
 		rtnl_unlock();
 	}
+	vfree(adapter->chan_stats);
 
 	up(sem);
 exit_sem_err:
@@ -1729,6 +1730,7 @@ int mwifiex_remove_card(struct mwifiex_a
 			mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
 		rtnl_unlock();
 	}
+	vfree(adapter->chan_stats);
 
 	wiphy_unregister(adapter->wiphy);
 	wiphy_free(adapter->wiphy);

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/pinctrl-rockchip-enable-clock-when-reading-pin-direction-register.patch queue-4.9/mwifiex-don-t-leak-chan_stats-on-reset.patch queue-4.9/platform-chrome-use-proper-protocol-transfer-function.patch