提交 a4d73ee1 编写于 作者: J Johannes Berg 提交者: David S. Miller

[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: NJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b86e0280
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册