* [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails
@ 2026-11-17 12:49 Daniel Machon
2026-11-17 12:53 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Machon @ 2026-11-17 12:49 UTC (permalink / raw)
To: Horatiu Vultur, UNGLinuxDriver, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Daniel Machon
lan966x_fdma_init() allocates the RX ring and fills its DCBs with pages
from the RX page pool, then allocates the TX ring. If the TX allocation
fails, the error path frees the RX ring and destroys the page pool, but
does not return the pages to the pool first.
The pool then never finishes its shutdown, and page_pool_release_retry()
keeps warning about the pages still in flight.
To let the pool shut down, return the RX pages before destroying it, as
lan966x_fdma_deinit() does. lan966x_fdma_rx_alloc() does not check that
every DCB got its pages, so skip the entries that are still empty.
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
index 1fbe910c5ec38..586ee648c7741 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
@@ -54,9 +54,11 @@ static void lan966x_fdma_rx_free_pages(struct lan966x_rx *rx)
int i, j;
for (i = 0; i < fdma->n_dcbs; ++i) {
- for (j = 0; j < fdma->n_dbs; ++j)
- page_pool_put_full_page(rx->page_pool,
- rx->page[i][j], false);
+ for (j = 0; j < fdma->n_dbs; ++j) {
+ if (rx->page[i][j])
+ page_pool_put_full_page(rx->page_pool,
+ rx->page[i][j], false);
+ }
}
}
@@ -999,6 +1001,7 @@ int lan966x_fdma_init(struct lan966x *lan966x)
err = lan966x_fdma_tx_alloc(&lan966x->tx);
if (err) {
+ lan966x_fdma_rx_free_pages(&lan966x->rx);
fdma_free_coherent(lan966x->dma_dev, &lan966x->rx.fdma);
page_pool_destroy(lan966x->rx.page_pool);
return err;
---
base-commit: 994089a3fa3882f27f4bed9fc5815ee7df502e88
change-id: 20261116-lan966x-rx-pages-tx-alloc-fail-2b8e412f15f2
Best regards,
--
Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails
2026-11-17 12:49 [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails Daniel Machon
@ 2026-11-17 12:53 ` netdev-bot+sinfo
2026-11-17 13:18 ` Nicolai Buchwitz
2026-11-18 13:08 ` netdev-bot+sashiko
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-17 12:53 UTC (permalink / raw)
To: Daniel Machon
Cc: Horatiu Vultur, UNGLinuxDriver, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails
2026-11-17 12:49 [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails Daniel Machon
2026-11-17 12:53 ` netdev-bot+sinfo
@ 2026-11-17 13:18 ` Nicolai Buchwitz
2026-11-18 13:08 ` netdev-bot+sashiko
2 siblings, 0 replies; 4+ messages in thread
From: Nicolai Buchwitz @ 2026-11-17 13:18 UTC (permalink / raw)
To: Daniel Machon
Cc: Horatiu Vultur, UNGLinuxDriver, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
On 17.11.2026 13:49, Daniel Machon wrote:
> lan966x_fdma_init() allocates the RX ring and fills its DCBs with pages
> from the RX page pool, then allocates the TX ring. If the TX allocation
> fails, the error path frees the RX ring and destroys the page pool, but
> does not return the pages to the pool first.
>
> The pool then never finishes its shutdown, and
> page_pool_release_retry()
> keeps warning about the pages still in flight.
>
> To let the pool shut down, return the RX pages before destroying it, as
> lan966x_fdma_deinit() does. lan966x_fdma_rx_alloc() does not check that
> every DCB got its pages, so skip the entries that are still empty.
>
> Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
> ---
> drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> index 1fbe910c5ec38..586ee648c7741 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> @@ -54,9 +54,11 @@ static void lan966x_fdma_rx_free_pages(struct
> lan966x_rx *rx)
> int i, j;
>
> for (i = 0; i < fdma->n_dcbs; ++i) {
> - for (j = 0; j < fdma->n_dbs; ++j)
> - page_pool_put_full_page(rx->page_pool,
> - rx->page[i][j], false);
> + for (j = 0; j < fdma->n_dbs; ++j) {
> + if (rx->page[i][j])
> + page_pool_put_full_page(rx->page_pool,
> + rx->page[i][j], false);
> + }
> }
> }
>
> @@ -999,6 +1001,7 @@ int lan966x_fdma_init(struct lan966x *lan966x)
>
> err = lan966x_fdma_tx_alloc(&lan966x->tx);
> if (err) {
> + lan966x_fdma_rx_free_pages(&lan966x->rx);
> fdma_free_coherent(lan966x->dma_dev, &lan966x->rx.fdma);
> page_pool_destroy(lan966x->rx.page_pool);
> return err;
>
> ---
> base-commit: 994089a3fa3882f27f4bed9fc5815ee7df502e88
> change-id: 20261116-lan966x-rx-pages-tx-alloc-fail-2b8e412f15f2
>
> Best regards,
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Regards
Nicolai
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails
2026-11-17 12:49 [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails Daniel Machon
2026-11-17 12:53 ` netdev-bot+sinfo
2026-11-17 13:18 ` Nicolai Buchwitz
@ 2026-11-18 13:08 ` netdev-bot+sashiko
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-18 13:08 UTC (permalink / raw)
To: daniel.machon
Cc: horatiu.vultur, UNGLinuxDriver, andrew+netdev, davem, edumazet,
kuba, pabeni, netdev, linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (2) · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] lan966x_fdma_rx_alloc() ignores the return value of
fdma_dcbs_init() (line 137).
- [Low] Missing Fixes:/Cc: stable tags.
Pre-existing issues:
- [High] NULL pointer dereference in the open-coded page-return loop of
lan966x_fdma_reload().
- [High] The new `if (rx->page[i][j])` check in
lan966x_fdma_rx_free_pages() assumes a slot without a page is NULL.
--
net: lan966x: free the RX pages when the TX allocation fails
When lan966x_fdma_tx_alloc() fails in lan966x_fdma_init(), this patch
returns the RX pages to the page pool before the pool is destroyed, so
the pool can finish shutting down. It also makes
lan966x_fdma_rx_free_pages() skip empty entries, because
lan966x_fdma_rx_alloc() does not check that every DCB got its pages.
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> index 1fbe910c5ec38..586ee648c7741 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> @@ -54,9 +54,11 @@ static void lan966x_fdma_rx_free_pages(struct lan966x_rx *rx)
> int i, j;
>
> for (i = 0; i < fdma->n_dcbs; ++i) {
> - for (j = 0; j < fdma->n_dbs; ++j)
> - page_pool_put_full_page(rx->page_pool,
> - rx->page[i][j], false);
> + for (j = 0; j < fdma->n_dbs; ++j) {
> + if (rx->page[i][j])
[Severity: Medium]
The commit message says "lan966x_fdma_rx_alloc() does not check that
every DCB got its pages, so skip the entries that are still empty".
Instead of treating a partly filled ring as normal here, would it be
better to check the return value of fdma_dcbs_init() in
lan966x_fdma_rx_alloc() and unwind?
lan966x_fdma_rx_alloc() {
...
fdma_dcbs_init(fdma, FDMA_DCB_INFO_DATAL(fdma->db_size),
FDMA_DCB_STATUS_INTR);
lan966x_fdma_llp_configure(lan966x, fdma->dma, fdma->channel_id);
return 0;
}
Say page_pool_dev_alloc_pages() fails in lan966x_fdma_rx_dataptr_cb()
at DCB k. Then __fdma_dcb_add() returns before it links prev->nextptr.
DCB k-1 keeps FDMA_DCB_INVALID_DATA as its next pointer, and DCB k and
the ones after it are never linked into the chain. Even so,
lan966x_fdma_rx_alloc() still returns 0.
lan966x_fdma_init() and lan966x_fdma_reload() then call
lan966x_fdma_rx_start() on the short chain. When NAPI has consumed DCBs
0..k-1, fdma_dcb_advance() moves dcb_index to k. From then on,
fdma_has_frames() in lan966x_fdma_napi_poll() polls a DCB that the
hardware never completes.
Can CPU RX stall permanently this way?
The PCI variant, lan966x_fdma_pci_rx_alloc(), already checks this call:
err = fdma_dcbs_init(fdma,
FDMA_DCB_INFO_DATAL(fdma->db_size - XDP_PACKET_HEADROOM),
FDMA_DCB_STATUS_INTR);
if (err) {
fdma_free_coherent_and_unmap(lan966x->dma_dev, fdma);
return err;
}
lan969x_fdma_rx_alloc() in sparx5 has the same unchecked call, and
lan969x_fdma_free_pages() has no NULL guard.
> + page_pool_put_full_page(rx->page_pool,
> + rx->page[i][j], false);
[Severity: High]
This is a pre-existing issue, but does the NULL check catch every slot
that no longer owns a page?
lan966x_fdma_rx_dataptr_cb() is the only writer of rx->page[dcb][db].
It does not clear the slot on -ENOMEM. Nothing else sets a slot back to
NULL after its page has been handed off. That means a slot is only
guaranteed to be NULL on the first init, when struct lan966x has just
been zeroed.
In lan966x_fdma_napi_poll(), lan966x_fdma_rx_get_frame() hands the page
to an skb, or lan966x_fdma_rx_free_page() recycles it, but the slot
keeps the pointer either way. The refill then ignores failure:
fdma_dcb_add(fdma, old_dcb, FDMA_DCB_INFO_DATAL(fdma->db_size),
FDMA_DCB_STATUS_INTR);
In lan966x_fdma_reload(), lan966x_fdma_rx_alloc() refills rx->page
without clearing it first. After a partial fill, the slots that were
not refilled still point at pages from the old pool. Those pages are
then returned to the old pool and freed by page_pool_destroy(page_pool).
Later, lan966x_fdma_deinit()->lan966x_fdma_rx_free_pages() or the next
reload puts these stale pointers into the current rx->page_pool.
Could that put a page twice while an skb still owns it, or put an
already freed page into a different pool?
Would it help to clear the slot whenever its page is given away, and
also check the return value of fdma_dcbs_init()?
> + }
> }
> }
[Severity: High]
This isn't a bug introduced by this patch, but if NULL slots are
expected here, what about the open-coded copy of this loop in
lan966x_fdma_reload()?
lan966x_fdma_reload() {
...
for (i = 0; i < fdma_rx_old.n_dcbs; ++i)
for (j = 0; j < fdma_rx_old.n_dbs; ++j)
page_pool_put_full_page(page_pool,
old_pages[i][j], false);
...
}
If the first fdma_dcbs_init() at probe stops partway, the rx->page[]
entries from DCB k onward stay NULL, and lan966x_fdma_rx_alloc() still
returns 0.
A later MTU change through lan966x_fdma_change_mtu(), or an XDP setup
through lan966x_fdma_reload_page_pool(), reaches lan966x_fdma_reload().
That function kmemdup()s those NULL entries into old_pages.
Once the new lan966x_fdma_rx_alloc() succeeds, this loop passes NULL to
page_pool_put_full_page(). That leads to page_pool_unref_netmem(), which
reads the pp_ref_count of a NULL netmem. Can this oops?
> @@ -999,6 +1001,7 @@ int lan966x_fdma_init(struct lan966x *lan966x)
>
> err = lan966x_fdma_tx_alloc(&lan966x->tx);
> if (err) {
> + lan966x_fdma_rx_free_pages(&lan966x->rx);
> fdma_free_coherent(lan966x->dma_dev, &lan966x->rx.fdma);
> page_pool_destroy(lan966x->rx.page_pool);
> return err;
[Severity: Low]
Should this patch have a Fixes: tag and go to net with Cc: stable?
The page_pool_destroy() call on this error path was added by commit
076344a6ad9d ("net: lan966x: fix page pool leak in error paths"), which
is tagged Cc: stable. Since that commit, the pool is destroyed while the
RX pages are still in flight. That causes the page_pool_release_retry()
warning described in this commit message.
Something like:
Fixes: 076344a6ad9d ("net: lan966x: fix page pool leak in error paths")
Without the tag, stable trees that picked up 076344a6ad9d would keep
the warning.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117-lan966x-rx-pages-tx-alloc-fail-v1-1-13f310d66650%40microchip.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-18 13:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 12:49 [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails Daniel Machon
2026-11-17 12:53 ` netdev-bot+sinfo
2026-11-17 13:18 ` Nicolai Buchwitz
2026-11-18 13:08 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®