OSDN Git Service

mt76: mt7921: fix possible NULL pointer dereference in mt7921_mac_write_txwi
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 18 Nov 2021 10:50:27 +0000 (11:50 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sun, 19 Dec 2021 14:23:59 +0000 (15:23 +0100)
Fix a possible NULL pointer deference issue in mt7921_mac_write_txwi
routine if vif is NULL.

Fixes: 33920b2bf0483 ("mt76: add support for setting mcast rate")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/mac.c

index 9bbbc0d..401f91c 100644 (file)
@@ -981,7 +981,7 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi,
                mt7921_mac_write_txwi_80211(dev, txwi, skb, key);
 
        if (txwi[2] & cpu_to_le32(MT_TXD2_FIX_RATE)) {
-               int rateidx = ffs(vif->bss_conf.basic_rates) - 1;
+               int rateidx = vif ? ffs(vif->bss_conf.basic_rates) - 1 : 0;
                u16 rate, mode;
 
                /* hardware won't add HTC for mgmt/ctrl frame */