Skip to content

Commit

Permalink
[WIRELESS] cfg80211: Fix locking in wiphy_new.
Browse files Browse the repository at this point in the history
This patch fixes the locking in wiphy new. Ingo Oeser
<[email protected]> noticed that locking in the error case was wrong and
also suggested this fix.

Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: John W. Linville <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jmberg authored and davem330 committed Apr 27, 2007
1 parent b86e028 commit a4d73ee
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions net/wireless/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,25 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)

mutex_lock(&cfg80211_drv_mutex);

if (unlikely(wiphy_counter<0)) {
drv->idx = wiphy_counter;

/* now increase counter for the next device unless
* it has wrapped previously */
if (wiphy_counter >= 0)
wiphy_counter++;

mutex_unlock(&cfg80211_drv_mutex);

if (unlikely(drv->idx < 0)) {
/* ugh, wrapped! */
kfree(drv);
return NULL;
}
drv->idx = wiphy_counter;

/* give it a proper name */
snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
PHY_NAME "%d", drv->idx);

/* now increase counter for the next time */
wiphy_counter++;
mutex_unlock(&cfg80211_drv_mutex);

mutex_init(&drv->mtx);
mutex_init(&drv->devlist_mtx);
INIT_LIST_HEAD(&drv->netdev_list);
Expand Down

0 comments on commit a4d73ee

Please sign in to comment.