linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wl12xx: Add mutex protection for interface list
@ 2011-03-21  8:43 juuso.oikarinen
  2011-03-21 15:43 ` Luciano Coelho
  0 siblings, 1 reply; 2+ messages in thread
From: juuso.oikarinen @ 2011-03-21  8:43 UTC (permalink / raw)
  To: coelho; +Cc: linux-wireless

From: Juuso Oikarinen <juuso.oikarinen@nokia.com>

The interface list maintained in main.c is not mutex protected. This could
cause issues, as the list is accessed from notifier chains.

Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
---
 drivers/net/wireless/wl12xx/main.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index db7ab85..1c09bfe 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -339,6 +339,7 @@ static struct platform_device wl1271_device = {
 	},
 };
 
+static DEFINE_MUTEX(wl_list_mutex);
 static LIST_HEAD(wl_list);
 
 static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
@@ -369,10 +370,12 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
 		return NOTIFY_DONE;
 
 	wl_temp = hw->priv;
+	mutex_lock(&wl_list_mutex);
 	list_for_each_entry(wl, &wl_list, list) {
 		if (wl == wl_temp)
 			break;
 	}
+	mutex_unlock(&wl_list_mutex);
 	if (wl != wl_temp)
 		return NOTIFY_DONE;
 
@@ -1390,8 +1393,10 @@ power_off:
 out:
 	mutex_unlock(&wl->mutex);
 
+	mutex_lock(&wl_list_mutex);
 	if (!ret)
 		list_add(&wl->list, &wl_list);
+	mutex_unlock(&wl_list_mutex);
 
 	return ret;
 }
@@ -1404,7 +1409,9 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
 
 	wl1271_info("down");
 
+	mutex_lock(&wl_list_mutex);
 	list_del(&wl->list);
+	mutex_unlock(&wl_list_mutex);
 
 	WARN_ON(wl->state != WL1271_STATE_ON);
 
-- 
1.7.1


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

* Re: [PATCH] wl12xx: Add mutex protection for interface list
  2011-03-21  8:43 [PATCH] wl12xx: Add mutex protection for interface list juuso.oikarinen
@ 2011-03-21 15:43 ` Luciano Coelho
  0 siblings, 0 replies; 2+ messages in thread
From: Luciano Coelho @ 2011-03-21 15:43 UTC (permalink / raw)
  To: juuso.oikarinen; +Cc: linux-wireless

On Mon, 2011-03-21 at 10:43 +0200, juuso.oikarinen@nokia.com wrote:
> From: Juuso Oikarinen <juuso.oikarinen@nokia.com>
> 
> The interface list maintained in main.c is not mutex protected. This could
> cause issues, as the list is accessed from notifier chains.
> 
> Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
> ---

Reviewed-by: Luciano Coelho <coelho@ti.com>

...and applied.  Thanks!

-- 
Cheers,
Luca.


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

end of thread, other threads:[~2011-03-21 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-21  8:43 [PATCH] wl12xx: Add mutex protection for interface list juuso.oikarinen
2011-03-21 15:43 ` Luciano Coelho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).