summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-05-10 19:23:40 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-07 12:52:23 -0700
commitc183f01b8c909323c42c77304f2fc4ad68cbd4a8 (patch)
treebc6f3e47a23bdf6fa0530bf5f749f5dc97f50901 /net
parentb380790737a4c11e034ddeb56832b2cac35af6f0 (diff)
cfg80211: fix wiphy_register error path
commit 03cd7e4e1ea16cd151c799a33b5ca1fd41a464df upstream. If rfkill_register() fails in wiphy_register() the struct device is unregistered but everything else isn't (regulatory, debugfs) and we even leave the wiphy instance on all internal lists even though it will likely be freed soon, which is clearly a problem. Fix this by cleaning up properly. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/wireless/core.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 6ddf74f0ae1e..ed56e2bc7ba8 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -638,17 +638,21 @@ int wiphy_register(struct wiphy *wiphy)
* cfg80211_mutex lock
*/
res = rfkill_register(rdev->rfkill);
- if (res)
- goto out_rm_dev;
+ if (res) {
+ device_del(&rdev->wiphy.dev);
+
+ mutex_lock(&cfg80211_mutex);
+ debugfs_remove_recursive(rdev->wiphy.debugfsdir);
+ list_del_rcu(&rdev->list);
+ wiphy_regulatory_deregister(wiphy);
+ mutex_unlock(&cfg80211_mutex);
+ return res;
+ }
rtnl_lock();
rdev->wiphy.registered = true;
rtnl_unlock();
return 0;
-
-out_rm_dev:
- device_del(&rdev->wiphy.dev);
- return res;
}
EXPORT_SYMBOL(wiphy_register);