aboutsummaryrefslogtreecommitdiff
path: root/net/mac80211/sta_info.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-03-31 19:23:02 +0200
committerJohn W. Linville <linville@tuxdriver.com>2008-04-01 17:14:10 -0400
commit4f6fab472c4c7c21d577f85fabec7628d4a05637 (patch)
tree0949dffadb0b715053e4d7148ebcabe930b39361 /net/mac80211/sta_info.c
parent93e5deb1ae39b56f4743955e76c72251256f23c1 (diff)
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: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/sta_info.c')
-rw-r--r--net/mac80211/sta_info.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 5497ca1843f..dfca96e05d6 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -180,13 +180,22 @@ void sta_info_destroy(struct sta_info *sta)
mesh_plink_deactivate(sta);
#endif
- /*
- * NOTE: This will call synchronize_rcu() internally to
- * make sure no key references can be in use. We rely on
- * that here for the mesh code!
- */
- ieee80211_key_free(sta->key);
- WARN_ON(sta->key);
+ if (sta->key) {
+ /*
+ * NOTE: This will call synchronize_rcu() internally to
+ * make sure no key references can be in use. We rely on
+ * that when we take this branch to make sure nobody can
+ * reference this STA struct any longer!
+ */
+ 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
if (ieee80211_vif_is_mesh(&sta->sdata->vif))
@@ -628,11 +637,9 @@ static void sta_info_debugfs_add_work(struct work_struct *work)
rate_control_add_sta_debugfs(sta);
sta = __sta_info_unpin(sta);
-
- if (sta) {
- synchronize_rcu();
- sta_info_destroy(sta);
- }
+ rtnl_lock();
+ sta_info_destroy(sta);
+ rtnl_unlock();
}
}
#endif
@@ -694,8 +701,6 @@ int sta_info_flush(struct ieee80211_local *local,
}
spin_unlock_irqrestore(&local->sta_lock, flags);
- synchronize_rcu();
-
list_for_each_entry_safe(sta, tmp, &tmp_list, list)
sta_info_destroy(sta);