aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/sta_info.c
diff options
context:
space:
mode:
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 42414b441592..909fa38edb6c 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 */