提交 7f0216a4 编写于 作者: J Johannes Berg 提交者: John W. Linville

mac80211: acquire sta_lock for station suspend/resume

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: NJohannes Berg <johannes@sipsolutions.net>
Acked-by: NBob Copeland <me@bobcopeland.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 8fdc621d
...@@ -10,6 +10,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) ...@@ -10,6 +10,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct ieee80211_if_init_conf conf; struct ieee80211_if_init_conf conf;
struct sta_info *sta; struct sta_info *sta;
unsigned long flags;
ieee80211_stop_queues_by_reason(hw, ieee80211_stop_queues_by_reason(hw,
IEEE80211_QUEUE_STOP_REASON_SUSPEND); IEEE80211_QUEUE_STOP_REASON_SUSPEND);
...@@ -21,9 +22,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) ...@@ -21,9 +22,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
ieee80211_disable_keys(sdata); ieee80211_disable_keys(sdata);
/* remove STAs */ /* remove STAs */
list_for_each_entry(sta, &local->sta_list, list) { if (local->ops->sta_notify) {
spin_lock_irqsave(&local->sta_lock, flags);
if (local->ops->sta_notify) { list_for_each_entry(sta, &local->sta_list, list) {
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss, sdata = container_of(sdata->bss,
struct ieee80211_sub_if_data, struct ieee80211_sub_if_data,
...@@ -32,11 +33,11 @@ int __ieee80211_suspend(struct ieee80211_hw *hw) ...@@ -32,11 +33,11 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
local->ops->sta_notify(hw, &sdata->vif, local->ops->sta_notify(hw, &sdata->vif,
STA_NOTIFY_REMOVE, &sta->sta); STA_NOTIFY_REMOVE, &sta->sta);
} }
spin_unlock_irqrestore(&local->sta_lock, flags);
} }
/* remove all interfaces */ /* remove all interfaces */
list_for_each_entry(sdata, &local->interfaces, list) { list_for_each_entry(sdata, &local->interfaces, list) {
if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
sdata->vif.type != NL80211_IFTYPE_MONITOR && sdata->vif.type != NL80211_IFTYPE_MONITOR &&
netif_running(sdata->dev)) { netif_running(sdata->dev)) {
...@@ -64,6 +65,7 @@ int __ieee80211_resume(struct ieee80211_hw *hw) ...@@ -64,6 +65,7 @@ int __ieee80211_resume(struct ieee80211_hw *hw)
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct ieee80211_if_init_conf conf; struct ieee80211_if_init_conf conf;
struct sta_info *sta; struct sta_info *sta;
unsigned long flags;
int res; int res;
/* restart hardware */ /* restart hardware */
...@@ -75,7 +77,6 @@ int __ieee80211_resume(struct ieee80211_hw *hw) ...@@ -75,7 +77,6 @@ int __ieee80211_resume(struct ieee80211_hw *hw)
/* add interfaces */ /* add interfaces */
list_for_each_entry(sdata, &local->interfaces, list) { list_for_each_entry(sdata, &local->interfaces, list) {
if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
sdata->vif.type != NL80211_IFTYPE_MONITOR && sdata->vif.type != NL80211_IFTYPE_MONITOR &&
netif_running(sdata->dev)) { netif_running(sdata->dev)) {
...@@ -87,9 +88,9 @@ int __ieee80211_resume(struct ieee80211_hw *hw) ...@@ -87,9 +88,9 @@ int __ieee80211_resume(struct ieee80211_hw *hw)
} }
/* add STAs back */ /* add STAs back */
list_for_each_entry(sta, &local->sta_list, list) { if (local->ops->sta_notify) {
spin_lock_irqsave(&local->sta_lock, flags);
if (local->ops->sta_notify) { list_for_each_entry(sta, &local->sta_list, list) {
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss, sdata = container_of(sdata->bss,
struct ieee80211_sub_if_data, struct ieee80211_sub_if_data,
...@@ -98,6 +99,7 @@ int __ieee80211_resume(struct ieee80211_hw *hw) ...@@ -98,6 +99,7 @@ int __ieee80211_resume(struct ieee80211_hw *hw)
local->ops->sta_notify(hw, &sdata->vif, local->ops->sta_notify(hw, &sdata->vif,
STA_NOTIFY_ADD, &sta->sta); STA_NOTIFY_ADD, &sta->sta);
} }
spin_unlock_irqrestore(&local->sta_lock, flags);
} }
/* add back keys */ /* add back keys */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册