Skip to contentSkip to conversation

mt76: mt76s: fix NULL pointer dereference in mt76s_process_tx_queue

PATCH New Lorenzo Bianconi 1 participant 1 message Dec 16, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mt76: mt76s: fix NULL pointer dereference in mt76s_process_tx_queue

Hi Kalle,

Since net-next is closed now I guess we can consider this patch for wireless-drivers

Regards,
Lorenzo

Fix a possible NULL pointer dereference in mt76s_process_tx_queue that can occur if status thread runs before allocating tx queues

Fixes 6a618acb7e62 ("mt76: sdio: convert {status/net}_work to mt76_worker")
---
 drivers/net/wireless/mediatek/mt76/sdio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/sdio.c +5 -1
index 7cd995118257..0b6facb17ff7 100644
@@ -157,10 +157,14 @@ static void mt76s_net_worker(struct mt76_worker *w)
 
 static int mt76s_process_tx_queue(struct mt76_dev *dev, struct mt76_queue *q)
 {
-	bool mcu = q == dev->q_mcu[MT_MCUQ_WM];
 	struct mt76_queue_entry entry;
 	int nframes = 0;
+	bool mcu;
 
+	if (!q)
+		return 0;
+
+	mcu = q == dev->q_mcu[MT_MCUQ_WM];
 	while (q->queued > 0) {
 		if (!q->entry[q->tail].done)
 			break;
Signature · 1 line
2.28.0