[PATCH 3/7] wifi: mt76: mt7925: guard HE 6 GHz capa lookup by HE iftype caps
Sean Wang
sean.wang at kernel.org
Wed Mar 4 15:50:16 PST 2026
From: Sean Wang <sean.wang at mediatek.com>
ieee80211_get_he_6ghz_capa() WARNs if the iftype has no sband iftype_data
or lacks HE. Probe HE support first with ieee80211_get_he_iftype_cap()
and only then query the 6 GHz capa. And initialize he_6ghz_capa/eht_cap
to avoid uninitialized use.
Co-developed-by: Stella Liu <yu-ching.liu at mediatek.com>
Signed-off-by: Stella Liu <yu-ching.liu at mediatek.com>
Signed-off-by: Sean Wang <sean.wang at mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
index e050c2795cb4..261ed6528808 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
@@ -2436,8 +2436,8 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
enum nl80211_band band,
struct ieee80211_link_sta *link_sta)
{
- struct ieee80211_he_6ghz_capa *he_6ghz_capa;
- const struct ieee80211_sta_eht_cap *eht_cap;
+ struct ieee80211_he_6ghz_capa *he_6ghz_capa = NULL;
+ const struct ieee80211_sta_eht_cap *eht_cap = NULL;
__le16 capa = 0;
u8 mode = 0;
@@ -2445,11 +2445,18 @@ mt7925_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
he_6ghz_capa = &link_sta->he_6ghz_capa;
eht_cap = &link_sta->eht_cap;
} else {
+ const struct ieee80211_sta_he_cap *he_cap;
struct ieee80211_supported_band *sband;
sband = phy->hw->wiphy->bands[band];
- capa = ieee80211_get_he_6ghz_capa(sband, vif->type);
- he_6ghz_capa = (struct ieee80211_he_6ghz_capa *)&capa;
+
+ he_cap = (band == NL80211_BAND_6GHZ) ?
+ ieee80211_get_he_iftype_cap(sband, vif->type) : NULL;
+
+ if (he_cap) {
+ capa = ieee80211_get_he_6ghz_capa(sband, vif->type);
+ he_6ghz_capa = (struct ieee80211_he_6ghz_capa *)&capa;
+ }
eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type);
}
--
2.43.0
More information about the Linux-mediatek
mailing list