From patchwork Wed Jul 21 15:21:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Bizon X-Patchwork-Id: 113376 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6LFLno8016946 for ; Wed, 21 Jul 2010 15:21:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599Ab0GUPVs (ORCPT ); Wed, 21 Jul 2010 11:21:48 -0400 Received: from smtp4-g21.free.fr ([212.27.42.4]:33127 "EHLO smtp4-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754005Ab0GUPVr (ORCPT ); Wed, 21 Jul 2010 11:21:47 -0400 Received: from bobafett.staff.proxad.net (unknown [213.228.1.121]) by smtp4-g21.free.fr (Postfix) with ESMTP id C704D4C8090; Wed, 21 Jul 2010 17:21:39 +0200 (CEST) Received: from [172.18.3.156] (unknown [172.18.3.156]) by bobafett.staff.proxad.net (Postfix) with ESMTP id BA4D8180407; Wed, 21 Jul 2010 17:21:38 +0200 (CEST) Subject: [PATCH] cfg80211: fix race between sysfs and cfg80211 From: Maxime Bizon Reply-To: mbizon@freebox.fr To: Johannes Berg Cc: linux-wireless@vger.kernel.org In-Reply-To: <1279394982.3931.0.camel@jlt3.sipsolutions.net> References: <1279336415.1941.6.camel@kero> <1279394982.3931.0.camel@jlt3.sipsolutions.net> Organization: Freebox Date: Wed, 21 Jul 2010 17:21:38 +0200 Message-ID: <1279725698.10426.4.camel@sakura.staff.proxad.net> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 21 Jul 2010 15:21:51 +0000 (UTC) diff --git a/net/wireless/core.c b/net/wireless/core.c index 6ac70c1..fd164db 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -472,24 +472,22 @@ int wiphy_register(struct wiphy *wiphy) /* check and set up bitrates */ ieee80211_set_bitrate_flags(wiphy); + mutex_lock(&cfg80211_mutex); + res = device_add(&rdev->wiphy.dev); if (res) - return res; + goto out_unlock; res = rfkill_register(rdev->rfkill); if (res) goto out_rm_dev; - mutex_lock(&cfg80211_mutex); - /* set up regulatory info */ wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); list_add_rcu(&rdev->list, &cfg80211_rdev_list); cfg80211_rdev_list_generation++; - mutex_unlock(&cfg80211_mutex); - /* add to debugfs */ rdev->wiphy.debugfsdir = debugfs_create_dir(wiphy_name(&rdev->wiphy), @@ -509,11 +507,15 @@ int wiphy_register(struct wiphy *wiphy) } cfg80211_debugfs_rdev_add(rdev); + mutex_unlock(&cfg80211_mutex); return 0; - out_rm_dev: +out_rm_dev: device_del(&rdev->wiphy.dev); + +out_unlock: + mutex_unlock(&cfg80211_mutex); return res; } EXPORT_SYMBOL(wiphy_register);