wifi: cfg80211: hold wiphy lock in cfg80211_any_wiphy_oper_chan()
authorJohannes Berg <johannes.berg@intel.com>
Mon, 28 Aug 2023 11:59:55 +0000 (13:59 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 11 Sep 2023 09:27:21 +0000 (11:27 +0200)
We have the RTNL here for the iteration, but we need to lock
each wiphy separately as well for using its data. Hold the
wiphy lock for all of the ones in the iteration. Note that
this implies we cannot already hold the wiphy mutex for the
wiphy passed by the argument, but that's true now.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/chan.c

index 3c691ae904d10f016235cd7691416ad4b4d68b45..b2469e2c1e706000b3a341eb14eeca446d87016f 100644 (file)
@@ -824,13 +824,17 @@ bool cfg80211_any_wiphy_oper_chan(struct wiphy *wiphy,
                return false;
 
        for_each_rdev(rdev) {
+               bool found;
+
                if (!reg_dfs_domain_same(wiphy, &rdev->wiphy))
                        continue;
 
-               if (cfg80211_is_wiphy_oper_chan(&rdev->wiphy, chan))
-                       return true;
+               wiphy_lock(&rdev->wiphy);
+               found = cfg80211_is_wiphy_oper_chan(&rdev->wiphy, chan) ||
+                       cfg80211_offchan_chain_is_active(rdev, chan);
+               wiphy_unlock(&rdev->wiphy);
 
-               if (cfg80211_offchan_chain_is_active(rdev, chan))
+               if (found)
                        return true;
        }