All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arbab Haider <arbabhaider649@gmail.com>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Théo Lebrun" <theo.lebrun@bootlin.com>,
	"Nicolai Buchwitz" <nb@tipi-net.de>,
	"Paolo Abeni" <pabeni@redhat.com>
Subject: [PATCH 7.0.y 3/5] net: macb: drop in-flight Tx SKBs on close
Date: Wed,  5 Aug 2026 15:01:34 +0500	[thread overview]
Message-ID: <20260805100136.59101-3-arbabhaider649@gmail.com> (raw)
In-Reply-To: <20260805100136.59101-1-arbabhaider649@gmail.com>

From: Théo Lebrun <theo.lebrun@bootlin.com>

The MACB driver has since forever leaked the outgoing SKBs that
have not yet been marked as completed. They live in queue->tx_skb
which gets freed without remorse nor checking.

macb_free_consistent() gets called in a few codepaths, but only close will
trigger the added expressions. In macb_open() and macb_alloc_consistent()
failure cases, queues' tx_skb just got allocated and are empty.

Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver")
Cc: stable@vger.kernel.org
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Link: https://patch.msgid.link/20260702-macb-drop-tx-v4-1-1c833eebdbc8@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
[ Upstream commit 27f575836cfebbf872dec020428742b10650a955 ]

---
 drivers/net/ethernet/cadence/macb_main.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 99e7d5cf3786..68dae92205e0 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2551,8 +2551,25 @@ static void macb_free_consistent(struct macb *bp)
 	dma_free_coherent(dev, size, bp->queues[0].rx_ring, bp->queues[0].rx_ring_dma);
 
 	for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
-		kfree(queue->tx_skb);
-		queue->tx_skb = NULL;
+		if (queue->tx_skb) {
+			unsigned int dropped = 0, tail;
+
+			for (tail = queue->tx_tail; tail != queue->tx_head;
+			     tail++) {
+				if (macb_tx_skb(queue, tail)->skb)
+					dropped++;
+				macb_tx_unmap(bp, macb_tx_skb(queue, tail), 0);
+			}
+
+			queue->stats.tx_dropped += dropped;
+			bp->dev->stats.tx_dropped += dropped;
+
+			kfree(queue->tx_skb);
+			queue->tx_skb = NULL;
+		}
+
+		queue->tx_head = 0;
+		queue->tx_tail = 0;
 		queue->tx_ring = NULL;
 		queue->rx_ring = NULL;
 	}
-- 
2.53.0


  parent reply	other threads:[~2026-08-05 10:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 10:01 [PATCH 7.0.y 1/5] net: mvneta: re-enable percpu interrupt on resume Arbab Haider
2026-08-05 10:01 ` [PATCH 7.0.y 2/5] net: mvneta: support EPROBE_DEFER when reading MAC address Arbab Haider
2026-08-05 10:01 ` Arbab Haider [this message]
2026-08-05 10:01 ` [PATCH 7.0.y 4/5] net: cpsw_new: unregister devlink on port registration failure Arbab Haider
2026-08-05 10:01 ` [PATCH 7.0.y 5/5] net: stmmac: fix transmit interrupt coalescing Arbab Haider
2026-08-05 16:41 ` [PATCH 7.0.y 1/5] net: mvneta: re-enable percpu interrupt on resume Sasha Levin
2026-08-05 18:37   ` Arbab Haider
2026-08-05 18:38   ` Arbab Haider
2026-08-06  4:44     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260805100136.59101-3-arbabhaider649@gmail.com \
    --to=arbabhaider649@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=theo.lebrun@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.