]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: Fix memory leak destroying device
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 8 Dec 2025 18:54:08 +0000 (19:54 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 23 Mar 2026 09:23:00 +0000 (09:23 +0000)
All MT76 rx queues have an associated page_pool even if the queue is not
associated to a NAPI (e.g. WED RRO queues with WED enabled). Destroy the
page_pool running mt76_dma_cleanup routine during module unload.
Moreover returns pages to the page pool if WED is not enabled for WED RRO
queues.

Fixes: 950d0abb5cd94 ("wifi: mt76: mt7996: add wed rx support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20251208-mt76-fix-memory-leak-v1-1-cba813fc62b8@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/dma.c

index f240016ed9f0ead27e98e350f4fdb818e1686781..893ac14285cab3c22f70945d490627a64b643efe 100644 (file)
@@ -874,7 +874,12 @@ mt76_dma_rx_cleanup(struct mt76_dev *dev, struct mt76_queue *q)
                if (!buf)
                        break;
 
-               if (!mt76_queue_is_wed_rro(q))
+               if (mtk_wed_device_active(&dev->mmio.wed) &&
+                   mt76_queue_is_wed_rro(q))
+                       continue;
+
+               if (!mt76_queue_is_wed_rro_rxdmad_c(q) &&
+                   !mt76_queue_is_wed_rro_ind(q))
                        mt76_put_page_pool_buf(buf, false);
        } while (1);
 
@@ -1168,10 +1173,6 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
        mt76_for_each_q_rx(dev, i) {
                struct mt76_queue *q = &dev->q_rx[i];
 
-               if (mtk_wed_device_active(&dev->mmio.wed) &&
-                   mt76_queue_is_wed_rro(q))
-                       continue;
-
                netif_napi_del(&dev->napi[i]);
                mt76_dma_rx_cleanup(dev, q);