aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/sta_info.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-02-27 03:56:40 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-03-06 15:30:47 -0500
commit03e4497ebeaa8011eb0ab0a54496ed6413b9d1a4 (patch)
tree96eb34d88a56f84f06f155e1d4a0d6d34d0f7933 /net/mac80211/sta_info.c
parentdbbea6713d6096cd1c411cb453a6b71292c78b33 (diff)
mac80211: fix sta_info mesh timer bug
I noticed a bug I introduced when mesh is enabled: sta_info_destroy() will end up calling cancel_timer() on a timer that has never been initialized because the timer is only initialized in mesh_plink_alloc(), not in sta_info_alloc(). This patch moves the initialization of all mesh related fields into sta_info_alloc(), adds a bit of sanity checking to the cfg80211 handlers and sta_info_insert() and makes mesh_plink_alloc() a static helper function that is only used from the mesh plink code. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Cc: Luis Carlos Cobo <luisca@cozybit.com> 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, 25 insertions, 8 deletions
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 42414b44159..909fa38edb6 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -31,13 +31,12 @@
31 * for faster lookup and a list for iteration. They are managed using 31 * for faster lookup and a list for iteration. They are managed using
32 * RCU, i.e. access to the list and hash table is protected by RCU. 32 * RCU, i.e. access to the list and hash table is protected by RCU.
33 * 33 *
34 * Upon allocating a STA info structure with sta_info_alloc() or 34 * Upon allocating a STA info structure with sta_info_alloc(), the caller owns
35 * mesh_plink_alloc(), the caller owns that structure. It must then either 35 * that structure. It must then either destroy it using sta_info_destroy()
36 * destroy it using sta_info_destroy() (which is pretty useless) or insert 36 * (which is pretty useless) or insert it into the hash table using
37 * it into the hash table using sta_info_insert() which demotes the reference 37 * sta_info_insert() which demotes the reference from ownership to a regular
38 * from ownership to a regular RCU-protected reference; if the function 38 * RCU-protected reference; if the function is called without protection by an
39 * is called without protection by an RCU critical section the reference 39 * RCU critical section the reference is instantly invalidated.
40 * is instantly invalidated.
41 * 40 *
42 * Because there are debugfs entries for each station, and adding those 41 * Because there are debugfs entries for each station, and adding those
43 * must be able to sleep, it is also possible to "pin" a station entry, 42 * must be able to sleep, it is also possible to "pin" a station entry,
@@ -248,6 +247,12 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
248 wiphy_name(local->hw.wiphy), print_mac(mbuf, sta->addr)); 247 wiphy_name(local->hw.wiphy), print_mac(mbuf, sta->addr));
249#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ 248#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
250 249
250#ifdef CONFIG_MAC80211_MESH
251 sta->plink_state = LISTEN;
252 spin_lock_init(&sta->plink_lock);
253 init_timer(&sta->plink_timer);
254#endif
255
251 return sta; 256 return sta;
252} 257}
253 258
@@ -258,7 +263,19 @@ int sta_info_insert(struct sta_info *sta)
258 unsigned long flags; 263 unsigned long flags;
259 DECLARE_MAC_BUF(mac); 264 DECLARE_MAC_BUF(mac);
260 265
261 WARN_ON(!netif_running(sdata->dev)); 266 /*
267 * Can't be a WARN_ON because it can be triggered through a race:
268 * something inserts a STA (on one CPU) without holding the RTNL
269 * and another CPU turns off the net device.
270 */
271 if (unlikely(!netif_running(sdata->dev)))
272 return -ENETDOWN;
273
274 if (WARN_ON(compare_ether_addr(sta->addr, sdata->dev->dev_addr) == 0))
275 return -EINVAL;
276
277 if (WARN_ON(is_multicast_ether_addr(sta->addr)))
278 return -EINVAL;
262 279
263 spin_lock_irqsave(&local->sta_lock, flags); 280 spin_lock_irqsave(&local->sta_lock, flags);
264 /* check if STA exists already */ 281 /* check if STA exists already */