wifi: mt76: connac: check for null before dereferencing
authorMuhammad Usama Anjum <usama.anjum@collabora.com>
Fri, 1 Mar 2024 14:44:06 +0000 (19:44 +0500)
committerFelix Fietkau <nbd@nbd.name>
Thu, 2 May 2024 10:44:50 +0000 (12:44 +0200)
The wcid can be NULL. It should be checked for validity before
dereferencing it to avoid crash.

Fixes: 098428c400ff ("wifi: mt76: connac: set correct muar_idx for mt799x chipsets")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

index b8927714d7e0ed017ad7463d06c764556d280824..6b18fc8141bf3955fd8a50d18f1a2cfd504d96f0 100644 (file)
@@ -283,7 +283,7 @@ __mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif,
        };
        struct sk_buff *skb;
 
-       if (is_mt799x(dev) && !wcid->sta)
+       if (is_mt799x(dev) && wcid && !wcid->sta)
                hdr.muar_idx = 0xe;
 
        mt76_connac_mcu_get_wlan_idx(dev, wcid, &hdr.wlan_idx_lo,