aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211_sta.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-02-21 08:09:30 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:41:34 -0500
commit43ba7e958f2ca05e4e9171a15402288419289d71 (patch)
tree15b7a04a7db402dd286f83cc56c21b336189da09 /net/mac80211/ieee80211_sta.c
parentd46e144b65bf053b25d134ec9f52a38e63e04bb4 (diff)
mac80211: atomically check whether STA exists already
When a STA structure is added, it is often checked whether it already exists before adding it. This, however, isn't done atomically so there is a race condition that could lead to two STA structures being added with the same MAC address. This patch changes sta_info_add() to return an ERR_PTR in case of failure and adds the failure mode -EEXIST when the STA already exists. 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/ieee80211_sta.c')
-rw-r--r--net/mac80211/ieee80211_sta.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index 8d620baba4fd..64476d9e8d77 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -1807,9 +1807,9 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
1807 if (!sta) { 1807 if (!sta) {
1808 struct ieee80211_sta_bss *bss; 1808 struct ieee80211_sta_bss *bss;
1809 sta = sta_info_add(local, dev, ifsta->bssid, GFP_KERNEL); 1809 sta = sta_info_add(local, dev, ifsta->bssid, GFP_KERNEL);
1810 if (!sta) { 1810 if (IS_ERR(sta)) {
1811 printk(KERN_DEBUG "%s: failed to add STA entry for the" 1811 printk(KERN_DEBUG "%s: failed to add STA entry for the"
1812 " AP\n", dev->name); 1812 " AP (error %ld)\n", dev->name, PTR_ERR(sta));
1813 return; 1813 return;
1814 } 1814 }
1815 bss = ieee80211_rx_bss_get(dev, ifsta->bssid, 1815 bss = ieee80211_rx_bss_get(dev, ifsta->bssid,
@@ -3820,7 +3820,7 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
3820 wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name); 3820 wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name);
3821 3821
3822 sta = sta_info_add(local, dev, addr, GFP_ATOMIC); 3822 sta = sta_info_add(local, dev, addr, GFP_ATOMIC);
3823 if (!sta) 3823 if (IS_ERR(sta))
3824 return NULL; 3824 return NULL;
3825 3825
3826 sta->flags |= WLAN_STA_AUTHORIZED; 3826 sta->flags |= WLAN_STA_AUTHORIZED;