All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue
@ 2022-03-21 22:55 Niels Dossche
  2022-04-06 11:44 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Niels Dossche @ 2022-03-21 22:55 UTC (permalink / raw)
  To: linux-wireless
  Cc: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Kalle Valo, Brian Norris, Niels Dossche

cfg80211_ch_switch_notify uses ASSERT_WDEV_LOCK to assert that
net_device->ieee80211_ptr->mtx (which is the same as priv->wdev.mtx)
is held during the function's execution.
mwifiex_dfs_chan_sw_work_queue is one of its callers, which does not
hold that lock, therefore violating the assertion.
Add a lock around the call.

Disclaimer:
I am currently working on a static analyser to detect missing locks.
This was a reported case. I manually verified the report by looking
at the code, so that I do not send wrong information or patches.
After concluding that this seems to be a true positive, I created
this patch.
However, as I do not in fact have this particular hardware,
I was unable to test it.

Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---
 drivers/net/wireless/marvell/mwifiex/11h.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/11h.c b/drivers/net/wireless/marvell/mwifiex/11h.c
index d2ee6469e67b..3fa25cd64cda 100644
--- a/drivers/net/wireless/marvell/mwifiex/11h.c
+++ b/drivers/net/wireless/marvell/mwifiex/11h.c
@@ -303,5 +303,7 @@ void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work)
 
 	mwifiex_dbg(priv->adapter, MSG,
 		    "indicating channel switch completion to kernel\n");
+	mutex_lock(&priv->wdev.mtx);
 	cfg80211_ch_switch_notify(priv->netdev, &priv->dfs_chandef);
+	mutex_unlock(&priv->wdev.mtx);
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue
  2022-03-21 22:55 [PATCH v2] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue Niels Dossche
@ 2022-04-06 11:44 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2022-04-06 11:44 UTC (permalink / raw)
  To: Niels Dossche
  Cc: linux-wireless, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu, Brian Norris, Niels Dossche

Niels Dossche <dossche.niels@gmail.com> wrote:

> cfg80211_ch_switch_notify uses ASSERT_WDEV_LOCK to assert that
> net_device->ieee80211_ptr->mtx (which is the same as priv->wdev.mtx)
> is held during the function's execution.
> mwifiex_dfs_chan_sw_work_queue is one of its callers, which does not
> hold that lock, therefore violating the assertion.
> Add a lock around the call.
> 
> Disclaimer:
> I am currently working on a static analyser to detect missing locks.
> This was a reported case. I manually verified the report by looking
> at the code, so that I do not send wrong information or patches.
> After concluding that this seems to be a true positive, I created
> this patch.
> However, as I do not in fact have this particular hardware,
> I was unable to test it.
> 
> Reviewed-by: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>

Patch applied to wireless-next.git, thanks.

3e12968f6d12 mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220321225515.32113-1-dossche.niels@gmail.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-06 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 22:55 [PATCH v2] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue Niels Dossche
2022-04-06 11:44 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.