]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mt76: mt7615: fix a possible NULL pointer dereference in mt7615_pm_wake_work
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 21 Aug 2020 10:09:54 +0000 (12:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:11:27 +0000 (10:11 +0100)
[ Upstream commit a081de174d11b12db9a94eb748041c2732f14c10 ]

Initialize wcid to global_wcid if msta is NULL in mt7615_pm_wake_work
routine since wcid will be dereferenced running mt76_tx()

Fixes: 2b8cdfb28d340 ("mt76: mt7615: wake device before pushing frames in mt7615_tx")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7615/mac.c

index 3dd8dd28690edc53f987f6a21c3d5107637d6e60..2be127018df6a040327376fd55031233afbc3e25 100644 (file)
@@ -1853,12 +1853,13 @@ void mt7615_pm_wake_work(struct work_struct *work)
        spin_lock_bh(&dev->pm.txq_lock);
        for (i = 0; i < IEEE80211_NUM_ACS; i++) {
                struct mt7615_sta *msta = dev->pm.tx_q[i].msta;
-               struct mt76_wcid *wcid = msta ? &msta->wcid : NULL;
                struct ieee80211_sta *sta = NULL;
+               struct mt76_wcid *wcid;
 
                if (!dev->pm.tx_q[i].skb)
                        continue;
 
+               wcid = msta ? &msta->wcid : &dev->mt76.global_wcid;
                if (msta && wcid->sta)
                        sta = container_of((void *)msta, struct ieee80211_sta,
                                           drv_priv);