wifi: cfg80211: reg: hold wiphy mutex for wdev iteration
authorJohannes Berg <johannes.berg@intel.com>
Mon, 28 Aug 2023 11:59:53 +0000 (13:59 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 11 Sep 2023 09:27:21 +0000 (11:27 +0200)
Since we will want to remove the wdev lock in the future,
lock the wiphy here to iterate and check the flags.

Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/reg.c

index f861d1d82b18428f85dfa37aef8800440571029b..1cdaf273d775930186df59b4538dc4dd59801fca 100644 (file)
@@ -3575,14 +3575,17 @@ static bool is_wiphy_all_set_reg_flag(enum ieee80211_regulatory_flags flag)
        struct wireless_dev *wdev;
 
        for_each_rdev(rdev) {
+               wiphy_lock(&rdev->wiphy);
                list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
                        wdev_lock(wdev);
                        if (!(wdev->wiphy->regulatory_flags & flag)) {
                                wdev_unlock(wdev);
+                               wiphy_unlock(&rdev->wiphy);
                                return false;
                        }
                        wdev_unlock(wdev);
                }
+               wiphy_unlock(&rdev->wiphy);
        }
 
        return true;