diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-04-26 23:50:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-04-26 23:50:35 -0400 |
commit | a4d73ee168eeaed3baea86542ad42e1fd7e192d3 (patch) | |
tree | c00fcd6915a2d92ecd15589566bbeb2d908ae87a /net | |
parent | b86e0280bb5585a610783ff5392d9d439dee7ddd (diff) |
[WIRELESS] cfg80211: Fix locking in wiphy_new.
This patch fixes the locking in wiphy new. Ingo Oeser
<netdev@axxeo.de> noticed that locking in the error case was wrong and
also suggested this fix.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/wireless/core.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c index 532e1e09e02..24a21add0ba 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -53,21 +53,25 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv) | |||
53 | 53 | ||
54 | mutex_lock(&cfg80211_drv_mutex); | 54 | mutex_lock(&cfg80211_drv_mutex); |
55 | 55 | ||
56 | if (unlikely(wiphy_counter<0)) { | 56 | drv->idx = wiphy_counter; |
57 | |||
58 | /* now increase counter for the next device unless | ||
59 | * it has wrapped previously */ | ||
60 | if (wiphy_counter >= 0) | ||
61 | wiphy_counter++; | ||
62 | |||
63 | mutex_unlock(&cfg80211_drv_mutex); | ||
64 | |||
65 | if (unlikely(drv->idx < 0)) { | ||
57 | /* ugh, wrapped! */ | 66 | /* ugh, wrapped! */ |
58 | kfree(drv); | 67 | kfree(drv); |
59 | return NULL; | 68 | return NULL; |
60 | } | 69 | } |
61 | drv->idx = wiphy_counter; | ||
62 | 70 | ||
63 | /* give it a proper name */ | 71 | /* give it a proper name */ |
64 | snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE, | 72 | snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE, |
65 | PHY_NAME "%d", drv->idx); | 73 | PHY_NAME "%d", drv->idx); |
66 | 74 | ||
67 | /* now increase counter for the next time */ | ||
68 | wiphy_counter++; | ||
69 | mutex_unlock(&cfg80211_drv_mutex); | ||
70 | |||
71 | mutex_init(&drv->mtx); | 75 | mutex_init(&drv->mtx); |
72 | mutex_init(&drv->devlist_mtx); | 76 | mutex_init(&drv->devlist_mtx); |
73 | INIT_LIST_HEAD(&drv->netdev_list); | 77 | INIT_LIST_HEAD(&drv->netdev_list); |