Commit 4f6fab47 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

mac80211: clean up sta_info_destroy() users wrt. RCU/locking

Calling sta_info_destroy() doesn't require RCU-synchronisation
before-hand because it does that internally. However, it does
require rtnl-locking so insert that where necessary.

Also clean up the code doing it internally to be a bit clearer and
not synchronize twice if keys are configured.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 93e5deb1
...@@ -700,11 +700,7 @@ static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, ...@@ -700,11 +700,7 @@ static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
return -ENOENT; return -ENOENT;
sta_info_unlink(&sta); sta_info_unlink(&sta);
sta_info_destroy(sta);
if (sta) {
synchronize_rcu();
sta_info_destroy(sta);
}
} else } else
sta_info_flush(local, sdata); sta_info_flush(local, sdata);
......
...@@ -939,7 +939,6 @@ static void ieee80211_associated(struct net_device *dev, ...@@ -939,7 +939,6 @@ static void ieee80211_associated(struct net_device *dev,
rcu_read_unlock(); rcu_read_unlock();
if (disassoc && sta) { if (disassoc && sta) {
synchronize_rcu();
rtnl_lock(); rtnl_lock();
sta_info_destroy(sta); sta_info_destroy(sta);
rtnl_unlock(); rtnl_unlock();
......
...@@ -180,13 +180,22 @@ void sta_info_destroy(struct sta_info *sta) ...@@ -180,13 +180,22 @@ void sta_info_destroy(struct sta_info *sta)
mesh_plink_deactivate(sta); mesh_plink_deactivate(sta);
#endif #endif
/* if (sta->key) {
* NOTE: This will call synchronize_rcu() internally to /*
* make sure no key references can be in use. We rely on * NOTE: This will call synchronize_rcu() internally to
* that here for the mesh code! * make sure no key references can be in use. We rely on
*/ * that when we take this branch to make sure nobody can
ieee80211_key_free(sta->key); * reference this STA struct any longer!
WARN_ON(sta->key); */
ieee80211_key_free(sta->key);
WARN_ON(sta->key);
} else {
/*
* Make sure that nobody can reference this STA struct
* any longer.
*/
synchronize_rcu();
}
#ifdef CONFIG_MAC80211_MESH #ifdef CONFIG_MAC80211_MESH
if (ieee80211_vif_is_mesh(&sta->sdata->vif)) if (ieee80211_vif_is_mesh(&sta->sdata->vif))
...@@ -628,11 +637,9 @@ static void sta_info_debugfs_add_work(struct work_struct *work) ...@@ -628,11 +637,9 @@ static void sta_info_debugfs_add_work(struct work_struct *work)
rate_control_add_sta_debugfs(sta); rate_control_add_sta_debugfs(sta);
sta = __sta_info_unpin(sta); sta = __sta_info_unpin(sta);
rtnl_lock();
if (sta) { sta_info_destroy(sta);
synchronize_rcu(); rtnl_unlock();
sta_info_destroy(sta);
}
} }
} }
#endif #endif
...@@ -694,8 +701,6 @@ int sta_info_flush(struct ieee80211_local *local, ...@@ -694,8 +701,6 @@ int sta_info_flush(struct ieee80211_local *local,
} }
spin_unlock_irqrestore(&local->sta_lock, flags); spin_unlock_irqrestore(&local->sta_lock, flags);
synchronize_rcu();
list_for_each_entry_safe(sta, tmp, &tmp_list, list) list_for_each_entry_safe(sta, tmp, &tmp_list, list)
sta_info_destroy(sta); sta_info_destroy(sta);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment