From: Lorenzo Bianconi Date: Thu, 14 Dec 2017 12:03:17 +0000 (+0100) Subject: mt76: fix possible NULL pointer dereferencing in mt76x2_mac_write_txwi() X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=98051872fd25077d3b106ab3d2b945fa7025c1ef;p=openwrt%2Fstaging%2Fblogic.git mt76: fix possible NULL pointer dereferencing in mt76x2_mac_write_txwi() Verify wcid is not NULL before dereferencing the pointer to initialize txwi rate/power info Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e") Signed-off-by: Lorenzo Bianconi Signed-off-by: Kalle Valo --- diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c index ecc23f58da98..f7c0df0759f7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mac.c @@ -186,7 +186,7 @@ void mt76x2_mac_write_txwi(struct mt76x2_dev *dev, struct mt76x2_txwi *txwi, txwi->pktid = 1; spin_lock_bh(&dev->mt76.lock); - if (rate->idx < 0 || !rate->count) { + if (wcid && (rate->idx < 0 || !rate->count)) { txwi->rate = wcid->tx_rate; max_txpwr_adj = wcid->max_txpwr_adj; nss = wcid->tx_rate_nss;