wifi: mac80211: don't use sband->band early
authorJohannes Berg <johannes.berg@intel.com>
Wed, 7 Feb 2024 10:59:20 +0000 (11:59 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 8 Feb 2024 14:00:44 +0000 (15:00 +0100)
Some drivers may (notably mt76 does) not set up sband->band
before registering, and cfg80211 will fill it in later. But
since the HT/HE capability check mac80211 required it to be
initialized already, otherwise failing things.  This really
isn't necessary though since the code is iterating the list
of bands, and has the 'band' variable available.  Fix it to
not require the sband->band to be initialized already.

Fixes: f04d2c247e04 ("wifi: mac80211: disallow drivers with HT wider than HE")
Reported-by: Bert Karwatzki <spasswolf@web.de>
Debugged-by: Bert Karwatzki <spasswolf@web.de>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218466
Link: https://msgid.link/20240207115920.43cbedffb5c3.I4968e12275a3f95926e3f3ccae81e50f23fe4d4d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/main.c

index 879abe216a3ee4708acce69713ff41c5bbb197b8..4eaea0a9975b474b0b6b314b3244a88d8e0f1d77 100644 (file)
@@ -1259,7 +1259,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
                        supp_he = supp_he || iftd->he_cap.has_he;
                        supp_eht = supp_eht || iftd->eht_cap.has_eht;
 
-                       if (sband->band == NL80211_BAND_2GHZ)
+                       if (band == NL80211_BAND_2GHZ)
                                he_40_mhz_cap =
                                        IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G;
                        else