aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/core.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-07-30 14:04:01 +0200
committerJohn W. Linville <linville@tuxdriver.com>2009-08-04 16:44:15 -0400
commite40cbdac0629402a4cb0c3bca0cc19ab7a00e00d (patch)
tree1bd8e7379d68af119ec91d07a1b85549cbe6b5f3 /net/wireless/core.c
parentiwlwifi: don't export symbols not needed in other modules (diff)
downloadlinux-dev-e40cbdac0629402a4cb0c3bca0cc19ab7a00e00d.tar.xz
linux-dev-e40cbdac0629402a4cb0c3bca0cc19ab7a00e00d.zip
cfg80211: fix NETDEV_UNREGISTER notifier
It's possible to get the NETDEV_UNREGISTER callback multiple times (see net/core/dev.c:netdev_wait_allrefs) and this will completely mess up our cleanup code. To avoid that, clean up only when the interface is still on the wiphy interface list from which it's removed on the first NETDEV_UNREGISTER call. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/core.c')
-rw-r--r--net/wireless/core.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 755cdf1643c9..1493285b6a4d 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -725,15 +725,22 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
break;
case NETDEV_UNREGISTER:
mutex_lock(&rdev->devlist_mtx);
+ /*
+ * It is possible to get NETDEV_UNREGISTER
+ * multiple times. To detect that, check
+ * that the interface is still on the list
+ * of registered interfaces, and only then
+ * remove and clean it up.
+ */
if (!list_empty(&wdev->list)) {
sysfs_remove_link(&dev->dev.kobj, "phy80211");
list_del_init(&wdev->list);
- }
- mutex_unlock(&rdev->devlist_mtx);
- mutex_destroy(&wdev->mtx);
+ mutex_destroy(&wdev->mtx);
#ifdef CONFIG_WIRELESS_EXT
- kfree(wdev->wext.keys);
+ kfree(wdev->wext.keys);
#endif
+ }
+ mutex_unlock(&rdev->devlist_mtx);
break;
case NETDEV_PRE_UP:
if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)))