* [PATCH net] net: stmmac: clear stale buf->page after recycling on skb build failure
@ 2026-09-21 14:46 Lorenzo Bianconi
2026-09-22 21:41 ` Maxime Chevallier
2026-09-24 2:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2026-09-21 14:46 UTC (permalink / raw)
To: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Yanteng Si, Alexander Lobakin, Furong Xu, Larysa Zaremba
Cc: netdev, linux-stm32, linux-arm-kernel, Lorenzo Bianconi
In stmmac_rx(), when napi_build_skb() fails the descriptor page is
recycled back to the page pool with page_pool_recycle_direct(), but
buf->page is left pointing at the recycled page, unlike every other
consumption site in the function which clears the pointer after handing
the page away.
With the stale pointer stmmac_rx_refill() skips the replacement
allocation and programs the already-recycled page back into the RX
descriptor.
Clear buf->page on the napi_build_skb() failure path to keep the buffer
lifecycle consistent with the other consumption sites.
Fixes: df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1fb5f804ea23..11035b7d944e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5887,6 +5887,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
if (!skb) {
page_pool_recycle_direct(rx_q->page_pool,
buf->page);
+ buf->page = NULL;
rx_dropped++;
count++;
goto drain_data;
---
base-commit: 1e24c4f2ee44be0eee94092b5d13cbdb4bdf0d60
change-id: 20260921-stmmac-fix-napi-build-skb-error-a02a3e839bd9
Best regards,
--
Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: stmmac: clear stale buf->page after recycling on skb build failure
2026-09-21 14:46 [PATCH net] net: stmmac: clear stale buf->page after recycling on skb build failure Lorenzo Bianconi
@ 2026-09-22 21:41 ` Maxime Chevallier
2026-09-24 2:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Chevallier @ 2026-09-22 21:41 UTC (permalink / raw)
To: Lorenzo Bianconi, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
Yanteng Si, Alexander Lobakin, Furong Xu, Larysa Zaremba
Cc: netdev, linux-stm32, linux-arm-kernel
Hi,
On 9/21/26 16:46, Lorenzo Bianconi wrote:
> In stmmac_rx(), when napi_build_skb() fails the descriptor page is
> recycled back to the page pool with page_pool_recycle_direct(), but
> buf->page is left pointing at the recycled page, unlike every other
> consumption site in the function which clears the pointer after handing
> the page away.
>
> With the stale pointer stmmac_rx_refill() skips the replacement
> allocation and programs the already-recycled page back into the RX
> descriptor.
>
> Clear buf->page on the napi_build_skb() failure path to keep the buffer
> lifecycle consistent with the other consumption sites.
>
> Fixes: df542f669307 ("net: stmmac: Switch to zero-copy in non-XDP RX path")
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 1fb5f804ea23..11035b7d944e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -5887,6 +5887,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
> if (!skb) {
> page_pool_recycle_direct(rx_q->page_pool,
> buf->page);
> + buf->page = NULL;
> rx_dropped++;
> count++;
> goto drain_data;
I'm not expert in the page_pool API, but this seems correct to me, the
doc says :
page_pool_recycle_direct() - release a reference on a page pool page
Seems to make sense to cleare the ref from buf->then ?
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
>
> ---
> base-commit: 1e24c4f2ee44be0eee94092b5d13cbdb4bdf0d60
> change-id: 20260921-stmmac-fix-napi-build-skb-error-a02a3e839bd9
>
> Best regards,
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: stmmac: clear stale buf->page after recycling on skb build failure
2026-09-21 14:46 [PATCH net] net: stmmac: clear stale buf->page after recycling on skb build failure Lorenzo Bianconi
2026-09-22 21:41 ` Maxime Chevallier
@ 2026-09-24 2:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-24 2:20 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
mcoquelin.stm32, alexandre.torgue, si.yanteng, aleksander.lobakin,
0x1207, larysa.zaremba, netdev, linux-stm32, linux-arm-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 21 Sep 2026 16:46:18 +0200 you wrote:
> In stmmac_rx(), when napi_build_skb() fails the descriptor page is
> recycled back to the page pool with page_pool_recycle_direct(), but
> buf->page is left pointing at the recycled page, unlike every other
> consumption site in the function which clears the pointer after handing
> the page away.
>
> With the stale pointer stmmac_rx_refill() skips the replacement
> allocation and programs the already-recycled page back into the RX
> descriptor.
>
> [...]
Here is the summary with links:
- [net] net: stmmac: clear stale buf->page after recycling on skb build failure
https://git.kernel.org/netdev/net/c/0a7822e34a0b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-24 2:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21 14:46 [PATCH net] net: stmmac: clear stale buf->page after recycling on skb build failure Lorenzo Bianconi
2026-09-22 21:41 ` Maxime Chevallier
2026-09-24 2:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox