From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: Bob Copeland <bcopeland@gmail.com>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: [PATCH] mac80211: acquire sta_lock for station suspend/resume
Date: Sat, 14 Mar 2009 09:42:49 +0100 [thread overview]
Message-ID: <1237020169.5235.66.camel@johannes.local> (raw)
To avoid concurrent manipulations of the sta list (which shouldn't
be possible at this point, but anyway) we need to hold the sta_lock
around iterating the list.
At the same time, we do not need to iterate the list at all if
the driver doesn't want to be notified.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
net/mac80211/pm.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
--- wireless-testing.orig/net/mac80211/pm.c 2009-03-14 09:35:01.000000000 +0100
+++ wireless-testing/net/mac80211/pm.c 2009-03-14 09:40:12.000000000 +0100
@@ -10,6 +10,7 @@ int __ieee80211_suspend(struct ieee80211
struct ieee80211_sub_if_data *sdata;
struct ieee80211_if_init_conf conf;
struct sta_info *sta;
+ unsigned long flags;
ieee80211_stop_queues_by_reason(hw,
IEEE80211_QUEUE_STOP_REASON_SUSPEND);
@@ -21,9 +22,9 @@ int __ieee80211_suspend(struct ieee80211
ieee80211_disable_keys(sdata);
/* remove STAs */
- list_for_each_entry(sta, &local->sta_list, list) {
-
- if (local->ops->sta_notify) {
+ if (local->ops->sta_notify) {
+ spin_lock_irqsave(&local->sta_lock, flags);
+ list_for_each_entry(sta, &local->sta_list, list) {
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
struct ieee80211_sub_if_data,
@@ -32,11 +33,11 @@ int __ieee80211_suspend(struct ieee80211
local->ops->sta_notify(hw, &sdata->vif,
STA_NOTIFY_REMOVE, &sta->sta);
}
+ spin_unlock_irqrestore(&local->sta_lock, flags);
}
/* remove all interfaces */
list_for_each_entry(sdata, &local->interfaces, list) {
-
if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
sdata->vif.type != NL80211_IFTYPE_MONITOR &&
netif_running(sdata->dev)) {
@@ -64,6 +65,7 @@ int __ieee80211_resume(struct ieee80211_
struct ieee80211_sub_if_data *sdata;
struct ieee80211_if_init_conf conf;
struct sta_info *sta;
+ unsigned long flags;
int res;
/* restart hardware */
@@ -75,7 +77,6 @@ int __ieee80211_resume(struct ieee80211_
/* add interfaces */
list_for_each_entry(sdata, &local->interfaces, list) {
-
if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
sdata->vif.type != NL80211_IFTYPE_MONITOR &&
netif_running(sdata->dev)) {
@@ -87,9 +88,9 @@ int __ieee80211_resume(struct ieee80211_
}
/* add STAs back */
- list_for_each_entry(sta, &local->sta_list, list) {
-
- if (local->ops->sta_notify) {
+ if (local->ops->sta_notify) {
+ spin_lock_irqsave(&local->sta_lock, flags);
+ list_for_each_entry(sta, &local->sta_list, list) {
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
struct ieee80211_sub_if_data,
@@ -98,6 +99,7 @@ int __ieee80211_resume(struct ieee80211_
local->ops->sta_notify(hw, &sdata->vif,
STA_NOTIFY_ADD, &sta->sta);
}
+ spin_unlock_irqrestore(&local->sta_lock, flags);
}
/* add back keys */
next reply other threads:[~2009-03-14 8:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-14 8:42 Johannes Berg [this message]
2009-03-14 23:40 ` [PATCH] mac80211: acquire sta_lock for station suspend/resume Bob Copeland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1237020169.5235.66.camel@johannes.local \
--to=johannes@sipsolutions.net \
--cc=bcopeland@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox