MLK-19091 cfg80211: make phy index match after wiphy dev is released
authorAndy Duan <fugang.duan@nxp.com>
Thu, 13 Sep 2018 09:23:37 +0000 (17:23 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
During insmod/rmmod test, the phy index increases that cause troube
for test case. To make global variable wiphy_counter match between
creat and free wiphy device, it needs to decrease the atomic counter
when wiphy device is freed.

Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
net/wireless/core.c

index a88551f..ba6083e 100644 (file)
@@ -41,6 +41,8 @@ MODULE_ALIAS_GENL_FAMILY(NL80211_GENL_NAME);
 LIST_HEAD(cfg80211_rdev_list);
 int cfg80211_rdev_list_generation;
 
+static atomic_t wiphy_counter = ATOMIC_INIT(0);
+
 /* for debugfs */
 static struct dentry *ieee80211_debugfs_dir;
 
@@ -383,8 +385,6 @@ static void cfg80211_propagate_cac_done_wk(struct work_struct *work)
 struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
                           const char *requested_name)
 {
-       static atomic_t wiphy_counter = ATOMIC_INIT(0);
-
        struct cfg80211_registered_device *rdev;
        int alloc_size;
 
@@ -995,6 +995,7 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
        }
        list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list)
                cfg80211_put_bss(&rdev->wiphy, &scan->pub);
+       atomic_dec(&wiphy_counter);
        kfree(rdev);
 }