Article View: linux.kernel.netdev
Article #18519Re: [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails
From: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 13:08
Date: Wed, 18 Nov 2026 13:08
182 lines
14920 bytes
14920 bytes
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
Technical Details
Message-ID:
<179500729408.3136.14303184286284983260@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366132-linux-kernel-netdev=dewy.ruReferences:
<20261117-lan966x-rx-pages-tx-alloc-fail-v1-1-13f310d66650@microchip.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366132-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] net: lan966x: free the RX pages when the TX allocation fails Date: Wed, 18 Nov 2026 13:08:14 +0000 Organization: Usenet Network Message-ID: <179500729408.3136.14303184286284983260@kernel.org> References: <20261117-lan966x-rx-pages-tx-alloc-fail-v1-1-13f310d66650@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2600102"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:1jp4/SaYnHNEcN6ULlkHeEHYt34= sha256:GslrPh/xA3DRymy6aZlYaovlWYjAO7Q2g25Mpj5epTw= sha1:IzOBLF6AC0O73evap8yd9zP4fkE= sha256:SHumdyoswqH55ifGfX67jNCSopgDyAgnfHndUr/FpFg= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 0F7511152A5; Wed, 18 Nov 2026 16:08:46 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WcYn-W90xuAB; Wed, 18 Nov 2026 16:08:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-366132-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 3B262115286; Wed, 18 Nov 2026 16:08:30 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 6927D34C05; Wed, 18 Nov 2026 13:08:24 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795007301; b=d6rFBUVTtZmWnhUtQCeNqNL3OPG2dKcVrilfBaHssvOFJ7q8S4bAsVdfoFjxRn+XwJhl V894XtA/K7zGlUwquSpz7yMvlQgy4qQbE0Qyu4P9SJAxnYfZm26GnKxkxvLrocYszfDmr knMYZBKf0WH2ZUyuEdwkodxQfJ1e4aq/cdMtsxT8l8Fe9zxfAIC2+b/J6RPh15lmKbU+s irMnDCX826GU5mHzmuADnOj02gRMFO/kD5fgbLHacR40S5I46cPqEKfbLgbRGiut62/59 Lg6iX4MKqCyriUqIVcSEMNDFfrg1yVW0u7GroZJPpXU0lZlzYlbgonpKy3b0zhEyNVw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795007301; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=XMxBAZKoUf1ggN391IrkLkELtekiqNvhy4TKd5GOQWo=; b=Rb+wUH++Xy1nO7ajtQz8FR+BF9pPADvhtnMiBI4e/gk1GsKNKgYIK1Ymg77v7CO1+Ll1 2vIVeKrzPi3+yrcSDu5w+1ovhuDEtfvPC4dibOQwZ6jGNNp5+LHOv4V5+HNdDUjX5WNpH hYL88ILk9cOCBey6x9r4P/Be5nyJbD6B7y58dzbC+w2YtxEcc4+li97igAY6mXostRi1U MwGzZ57fBXyxJ+NW26gSzu6ILr7NHgmwI/MoMBvFjlsRVhVOOjbMTI+xdpp/ivmQZpTXV vXpwTpMZ9CTYCrFQeM+/++3vD9zibVJeTjZMRNUY59bmzzS7ESamwba9Sef+5SsRdAg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jb4Arz6B; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61EBC606A332; Wed, 18 Nov 2026 13:08:21 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jb4Arz6B X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795007295; b=mXDCL4siCo7s/zt9Ovgc7fCHBC2oplyOp6BBxkLVKWBfbgkN6IGrvgdzuaaGshnDFBKb VcruhAt7tF/kkFmboYxwqV8C6QrgLziB4x1/q71+qE02JGCeDzdwblAgfKETUzugMzNXi JgkcuxfDlFyO8HzvmDRxoPwpqzen/CStXXKRIiCZG5G43x14NVvuE8CjY51UEJ8xbkrI0 8U2n6+6B9r82dVNFYTcJPrz7/5d1V9VPeWM8IUa00uDxmNygM/5MIMz8OS78LYGnJmdkP qa3CUQ8CQtOywsYPMNGW82HOzE4LUOFjgdEiBPp8FJlFS4aHUthEV5ba/cnEPIrIcpg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795007295; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=XMxBAZKoUf1ggN391IrkLkELtekiqNvhy4TKd5GOQWo=; b=PRJNtYwzqmBx9kRwkihc9XPV1KDK2sd+BQ2JVvX8lqIWhof4y9nPYepSkA4fjMuS0RuP 8LDRJ5Qn0SwRBqR/LR0PrAb0AQ5czJyXB8UNn+KQ9Lan30aQa8338+OIb5B3jOWJt15qw LkG7bBhQM6fgRPN/MmgV6QO4si3S4pZE065ff1Ql/eyjT6lg9A+cWKQijZFgnXFRli6D6 x6/cyQMrQf5zxO7aPooZW1Ls80eJZ4ZZHeeFgvEwlmh7WKdV1cNYcpGlCSgS013Gpw0Ta /SbYmyCgrkuStf0XuXI1ZPtdszX6+0iBfS7YgMYbq77DNRtZzmowcVYEXJAcVVX1pbg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jb4Arz6B; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A85B606A31C; Wed, 18 Nov 2026 13:08:15 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9147E1F000C5; Wed, 18 Nov 2026 13:08:14 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795007295; bh=XMxBAZKoUf1ggN391IrkLkELtekiqNvhy4TKd5GOQWo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=jb4Arz6B3rLViZPvjRIi1bycg63lG6DfOTljVPW4v0Yr0robamxuxunHi9l5xzoX8 d5YPJphrHKTsnjuTIxnooUZ1HdK5QP+8fuemkr8DYsHIIYlstVA+q07c17n5EHOYCv hFOvYsoncXtOXDq0zRFpjwzHuobUP8WrvaC5EnloiK7oWhS5slTNbKZb0SL9GDENVa PQX+/7wG5lkRx5vpYUE5mzPxpwJ52veqmroJ3rGXmZHM2AR/1ZDt7sVUTPYtsLejoM QbGzJQvQCidQhNGQRRS27fnBNTaqnhYHq1mM0bwQfBroQKjOWPUlRi+K6HgHRd3TVb IMBT5U7F9BxRg== X-Cc: horatiu.vultur@microchip.com, UNGLinuxDriver@microchip.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261117-lan966x-rx-pages-tx-alloc-fail-v1-1-13f310d66650@microchip.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list