From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Théo Lebrun" <theo.lebrun@bootlin.com>,
"Nicolai Buchwitz" <nb@tipi-net.de>,
"Paolo Abeni" <pabeni@redhat.com>,
"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.15.y 6/6] net: macb: drop in-flight Tx SKBs on close
Date: Wed, 29 Jul 2026 12:24:27 -0400 [thread overview]
Message-ID: <20260729162427.3522161-6-sashal@kernel.org> (raw)
In-Reply-To: <20260729162427.3522161-1-sashal@kernel.org>
From: Théo Lebrun <theo.lebrun@bootlin.com>
[ Upstream commit 27f575836cfebbf872dec020428742b10650a955 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 aae3f3e98b3966..3ac22aa25d9c32 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2382,8 +2382,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
prev parent reply other threads:[~2026-07-29 16:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 9:14 FAILED: patch "[PATCH] net: macb: drop in-flight Tx SKBs on close" failed to apply to 5.15-stable tree gregkh
2026-07-29 16:24 ` [PATCH 5.15.y 1/6] net: macb: simplify/cleanup NAPI reschedule checking Sasha Levin
2026-07-29 16:24 ` [PATCH 5.15.y 2/6] net: macb: use NAPI for TX completion path Sasha Levin
2026-07-29 16:24 ` [PATCH 5.15.y 3/6] net: macb: remove illusion about TBQPH/RBQPH being per-queue Sasha Levin
2026-07-29 16:24 ` [PATCH 5.15.y 4/6] net: macb: move ring size computation to functions Sasha Levin
2026-07-29 16:24 ` [PATCH 5.15.y 5/6] net: macb: single dma_alloc_coherent() for DMA descriptors Sasha Levin
2026-07-29 16:24 ` Sasha Levin [this message]
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=20260729162427.3522161-6-sashal@kernel.org \
--to=sashal@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.