]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: cfg80211: make sure NAN chandefs are valid
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 18 Mar 2026 12:39:16 +0000 (14:39 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 25 Mar 2026 19:56:05 +0000 (20:56 +0100)
Until now there was not handling for NAN in reg_wdev_chan_valid.
Now as this wdev might use chandefs, check the validity of those.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260108102921.51b42ffc9a42.Iacb030fc17027afb55707ca1d6dc146631d55767@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260219094725.3846371-4-miriam.rachel.korenblit@intel.com
Link: https://patch.msgid.link/20260318123926.206536-3-miriam.rachel.korenblit@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/reg.c

index 20bba7e491c5e65cdf4f59179d8c339b0f91e23a..4b5450aec72ed9132e7fd4fb2d66e1af1efd7320 100644 (file)
@@ -2348,6 +2348,18 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
        if (!wdev->netdev || !netif_running(wdev->netdev))
                return true;
 
+       /* NAN doesn't have links, handle it separately */
+       if (iftype == NL80211_IFTYPE_NAN) {
+               for (int i = 0; i < wdev->u.nan.n_channels; i++) {
+                       ret = cfg80211_reg_can_beacon(wiphy,
+                                                     &wdev->u.nan.chandefs[i],
+                                                     NL80211_IFTYPE_NAN);
+                       if (!ret)
+                               return false;
+               }
+               return true;
+       }
+
        for (link = 0; link < ARRAY_SIZE(wdev->links); link++) {
                struct ieee80211_channel *chan;
 
@@ -2397,9 +2409,6 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
                                continue;
                        chandef = wdev->u.ocb.chandef;
                        break;
-               case NL80211_IFTYPE_NAN:
-                       /* we have no info, but NAN is also pretty universal */
-                       continue;
                default:
                        /* others not implemented for now */
                        WARN_ON_ONCE(1);