wifi: mt76: Fix NULL Dereference caused by mt76_connac_get_he_phy_cap()
Subsystems (2)
PATCH v6 1/1 wifi: mt76: Fix NULL Dereference caused by mt76_connac_get_he_phy_cap()
From: Zichen Xie <[email protected]>
mt76_connac_get_he_phy_cap() may return a NULL pointer, leading to NULL Pointer Dereference.
Add a NULL check for the returned pointer.
---
v5: Add version tag.
v6: Adjust NULL check position for readability.
--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 2 ++ 3 files changed, 9 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +5 -0
@@ -551,6 +551,8 @@ mt7915_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!cap) +return ; tlv =mt76_connac_mcu_add_tlv (skb,BSS_INFO_HE_BASIC ,sizeof (*he));
@@ -1140,6 +1142,9 @@ mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem;const struct ieee80211_sta_he_cap *vc =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!vc) +return ; +const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem;u16 mcs_map =le16_to_cpu (pc->he_mcs_nss_supp.rx_mcs_80);u8 nss_mcs =mt7915_mcu_get_sta_nss (mcs_map);
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +2 -0
@@ -2508,6 +2508,8 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *link_conf,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, link_conf->vif); +if (!cap) +return ; tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_HE_BASIC ,sizeof (*he));
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +2 -0
@@ -798,6 +798,8 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!cap) +return ; tlv =mt7996_mcu_add_uni_tlv (skb,UNI_BSS_INFO_HE_BASIC ,sizeof (*he));
Signature · 1 line
2.25.1
Quoted 33 lines · Gax-c
From: Zichen Xie <[email protected]>
mt76_connac_get_he_phy_cap()may return a NULL pointer, leading to NULL Pointer Dereference.
Add a NULL check for the returned pointer.Fixes a5c372f77aa7 ("wifi: mt76: mt7925: extend mt7925_mcu_bss_he_tlv for per-link BSS")Fixes e6d557a78b60 ("mt76: mt7915: rely on mt76_connac_get_phy utilities")Fixes 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")Signed-off-by Zichen Xie <[email protected]>---
v5: Add version tag.
v6: Adjust NULL check position for readability.--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 2 ++ 3 files changed, 9 insertions(+)drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +2
-0@@ -551,6 +551,8 @@ mt7915_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!cap) +return ; tlv =mt76_connac_mcu_add_tlv (skb,BSS_INFO_HE_BASIC ,sizeof (*he));
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, · line 1147
Quoted 6 lines
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +3
-0@@ -1140,6 +1142,9 @@ mt7915_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif,struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem;const struct ieee80211_sta_he_cap *vc =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!vc) +return ; +
Nope. Splitting declarations is a no.
One of your patches did not even build, although for few emails you were insisting everything is fine. This is not even close to Linux coding style.
Please carefully read Documentation/process before posting new patches.
Best regards,
Krzysztof
A message that is not in the archive (sent off-list or not yet received): CANdh5G4r_WVt3ao0sFqFA7F3BUHi9wNwWENVHjPXyRGq2sotZA@mail.gmail.com
Quoted 3 lines · Zichen Xie
Hi,
But Matthias suggested checking for NULL immediately after the declaration.
Why do you keep top-posting? Matthias also asked you to stop, so that part you ignore? Responding to such HTML, top-post emails is a pain, so that is the last time I am writing here. I will be NAK-ing other totally bogus and untested patches, though.
Quoted 3 lines
Re: [PATCH v5] wifi: mt76: Fix NULL Dereference caused by
mt76_connac_get_he_phy_cap()- Matthias Brugger (kernel.org)
<https://lore.kernel.org/all/[email protected]/>
Don't send HTML. Anyway I do not see anything indicating that this should be before declarations. I see clearly: "before any use of struct vc." which is not before declarations.
Best regards,
Krzysztof