Skip to contentSkip to conversation

FAILED: patch "[PATCH] net: stmmac: drop the rest of the frame when napi_build_skb()" failed to apply to 6.6-stable tree

PATCH New [email protected] 2 participants 2 messages Dec 2 – Dec 4

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x ece404eac250fc4be7aa4cec82e8c248cca83c28
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026120213-mocha-handyman-a43d@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ece404eac250fc4be7aa4cec82e8c248cca83c28 Mon Sep 17 00:00:00 2001
From: Arun Iyengar <[email protected]>
Date: Fri, 13 Nov 2026 17:13:40 +0000
Subject: [PATCH] net: stmmac: drop the rest of the frame when napi_build_skb()
fails

If napi_build_skb() fails on the first buffer of a frame that spans several descriptors, stmmac_rx() drops that buffer but goes on with the next descriptor of the same frame as if a new frame started there. The rest of the frame is then passed up the stack as a frame of its own. A frame spans several descriptors when it does not fit in the RX buffers of one descriptor.

Mark the frame as errored instead, so that its remaining descriptors are discarded like those of a frame with a receive error. The frame is counted once in rx_dropped and once against the NAPI budget.

Found while working on the sun8i EMAC jumbo frame series, where frames over 2032 bytes span several descriptors. Tested on an Orange Pi Zero2 (dwmac-sun8i, MTU 4070), w/ jumbo series and error injection.

Fixes ec222003bd94 ("net: stmmac: Prepare to add Split Header support")
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
index ee63f5ecf570..9a9c44aab2e4 100644
@@ -6045,7 +6045,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 							 buf->page);
 				buf->page = NULL;
 				rx_dropped++;
-				count++;
+				error = 1;
 				goto drain_data;
 			}
 
@@ -6081,7 +6081,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 		if (likely(status & rx_not_ls))
 			goto read_again;
 		if (!skb)
-			continue;
+			goto next;
 
 		/* Got entire packet into SKB. Finish it. */
 
maintainer
#1 lore raw

PATCH 1/1 net: stmmac: drop the rest of the frame when napi_build_skb() fails

From: Arun Iyengar <[email protected]>

[ Upstream commit ece404eac250fc4be7aa4cec82e8c248cca83c28 ]

If napi_build_skb() fails on the first buffer of a frame that spans several descriptors, stmmac_rx() drops that buffer but goes on with the next descriptor of the same frame as if a new frame started there. The rest of the frame is then passed up the stack as a frame of its own. A frame spans several descriptors when it does not fit in the RX buffers of one descriptor.

Mark the frame as errored instead, so that its remaining descriptors are discarded like those of a frame with a receive error. The frame is counted once in rx_dropped and once against the NAPI budget.

Found while working on the sun8i EMAC jumbo frame series, where frames over 2032 bytes span several descriptors. Tested on an Orange Pi Zero2 (dwmac-sun8i, MTU 4070), w/ jumbo series and error injection.

Fixes ec222003bd94 ("net: stmmac: Prepare to add Split Header support")
[ sashal: Context differs because this tree uses napi_alloc_skb() rather than napi_build_skb(), and with no next: label, goto next became count++; continue; in the !skb branch after drain_data. ]
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -2
index 052de50863bff..b7e1a4123d7b0 100644
@@ -5509,7 +5509,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 			skb = napi_alloc_skb(&ch->rx_napi, buf1_len);
 			if (!skb) {
 				rx_dropped++;
-				count++;
+				error = 1;
 				goto drain_data;
 			}
 
@@ -5547,8 +5547,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 drain_data:
 		if (likely(status & rx_not_ls))
 			goto read_again;
-		if (!skb)
+		if (!skb) {
+			count++;
 			continue;
+		}
 
 		/* Got entire packet into SKB. Finish it. */
 
Signature · 1 line
2.53.0