mt76: mt76x02: do not access uninitialized NAPI structs
authorFelix Fietkau <nbd@nbd.name>
Mon, 15 Jun 2020 18:13:41 +0000 (20:13 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 23 Jun 2020 08:42:37 +0000 (11:42 +0300)
Fixes a crash on MMIO devices when running into the watchdog reset

Fixes: d3377b78cec6 ("mt76: add HE phy modes and hardware queue")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200615181341.81871-1-nbd@nbd.name
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c

index cbbe986655fe50c414f9219418e9ea217a5babed..5fda6e7b120c20c83c06dcd1e21af4cb2d944946 100644 (file)
@@ -456,8 +456,9 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev)
        tasklet_disable(&dev->mt76.tx_tasklet);
        napi_disable(&dev->mt76.tx_napi);
 
-       for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++)
+       mt76_for_each_q_rx(&dev->mt76, i) {
                napi_disable(&dev->mt76.napi[i]);
+       }
 
        mutex_lock(&dev->mt76.mutex);
 
@@ -515,7 +516,7 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev)
 
        tasklet_enable(&dev->mt76.pre_tbtt_tasklet);
 
-       for (i = 0; i < ARRAY_SIZE(dev->mt76.napi); i++) {
+       mt76_for_each_q_rx(&dev->mt76, i) {
                napi_enable(&dev->mt76.napi[i]);
                napi_schedule(&dev->mt76.napi[i]);
        }