Netdev List
 help / color / mirror / Atom feed
* [PATCH net] ice: fix XDP ring leaks on setup failures
@ 2026-11-29  5:59 Jaeyeong Lee
  2026-11-29  6:03 ` netdev-bot+sinfo
  2026-11-30  6:02 ` netdev-bot+sashiko
  0 siblings, 2 replies; 4+ messages in thread
From: Jaeyeong Lee @ 2026-11-29  5:59 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel
  Cc: Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	intel-wired-lan, netdev, bpf, Jaeyeong Lee, stable

When the ring statistics allocation fails, the XDP ring has not yet
been published in vsi->xdp_rings. ice_free_tx_ring() only releases
the resources owned by the ring, not the ring allocation itself, so
the ring is leaked.

If ice_setup_tx_ring() fails, it leaves desc NULL. The unwind loop
consequently skips that ring and leaks its ring statistics. The caller
releases the ring allocation, but not the statistics allocation.

Free an unpublished ring directly when statistics allocation fails.
Unwind every published ring regardless of whether descriptor
allocation completed so that both fully and partially initialized
rings release their resources.

Fixes: 288ecf491b16 ("ice: Accumulate ring statistics over reset")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
---
 drivers/net/ethernet/intel/ice/ice_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 47c6798c9..522492d58 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2542,7 +2542,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
 
 		ring_stats = kzalloc_obj(*ring_stats);
 		if (!ring_stats) {
-			ice_free_tx_ring(xdp_ring);
+			kfree(xdp_ring);
 			goto free_xdp_rings;
 		}
 
@@ -2568,7 +2568,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
 
 free_xdp_rings:
 	for (; i >= 0; i--) {
-		if (vsi->xdp_rings[i] && vsi->xdp_rings[i]->desc) {
+		if (vsi->xdp_rings[i]) {
 			kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu);
 			vsi->xdp_rings[i]->ring_stats = NULL;
 			ice_free_tx_ring(vsi->xdp_rings[i]);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] ice: fix XDP ring leaks on setup failures
  2026-11-29  5:59 [PATCH net] ice: fix XDP ring leaks on setup failures Jaeyeong Lee
@ 2026-11-29  6:03 ` netdev-bot+sinfo
  2026-11-29  8:03   ` Jaeyeong Lee
  2026-11-30  6:02 ` netdev-bot+sashiko
  1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-29  6:03 UTC (permalink / raw)
  To: Jaeyeong Lee
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Stanislav Fomichev, intel-wired-lan, netdev, bpf, stable

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] ice: fix XDP ring leaks on setup failures
  2026-11-29  6:03 ` netdev-bot+sinfo
@ 2026-11-29  8:03   ` Jaeyeong Lee
  0 siblings, 0 replies; 4+ messages in thread
From: Jaeyeong Lee @ 2026-11-29  8:03 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Stanislav Fomichev, intel-wired-lan, netdev, bpf, stable

Hi,

This issue was found by a static analysis tool, and the patch was tested
under QEMU.

Thanks,
Jaeyeong


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] ice: fix XDP ring leaks on setup failures
  2026-11-29  5:59 [PATCH net] ice: fix XDP ring leaks on setup failures Jaeyeong Lee
  2026-11-29  6:03 ` netdev-bot+sinfo
@ 2026-11-30  6:02 ` netdev-bot+sashiko
  1 sibling, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-30  6:02 UTC (permalink / raw)
  To: lee
  Cc: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
	edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend, sdf,
	intel-wired-lan, netdev, bpf, stable

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

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).

- [High] The patch is titled "ice: fix XDP ring leaks on setup failures"
  and blames 288ecf491b16, but one setup-failure path in…

--

ice: fix XDP ring leaks on setup failures

This patch changes the error unwind in ice_xdp_alloc_setup_rings(). If
the ring_stats allocation fails, the unpublished XDP ring is now freed
directly. The free_xdp_rings loop now unwinds every published ring,
including those whose descriptor allocation did not complete.

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 47c6798c97e8f..522492d58c507 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c

[ ... ]

> @@ -2568,7 +2568,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
>  
>  free_xdp_rings:
>  	for (; i >= 0; i--) {
> -		if (vsi->xdp_rings[i] && vsi->xdp_rings[i]->desc) {
> +		if (vsi->xdp_rings[i]) {
>  			kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu);
>  			vsi->xdp_rings[i]->ring_stats = NULL;
>  			ice_free_tx_ring(vsi->xdp_rings[i]);

[Severity: High]
This fixes the two unwind cases inside ice_xdp_alloc_setup_rings(). Is
there still a setup failure in the caller, ice_prepare_xdp_rings(), that
leaks the same ring_stats allocation from 288ecf491b16?

When ice_xdp_alloc_setup_rings() succeeds, every vsi->xdp_rings[i] owns
a kzalloc'd ring_stats, a devm tx_buf array and a dmam descriptor ring.
When cfg_type is not ICE_XDP_CFG_PART, the caller then does:

drivers/net/ethernet/intel/ice/ice_main.c:ice_prepare_xdp_rings() {
    ...
	status = ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc,
				 max_txqs);
	if (status) {
		dev_err(dev, "Failed VSI LAN queue config for XDP, error: %d\n",
			status);
		goto unmap_xdp_rings;
	}
    ...
unmap_xdp_rings:
	ice_unmap_xdp_rings(vsi);
clear_xdp_rings:
	ice_for_each_xdp_txq(vsi, i)
		if (vsi->xdp_rings[i]) {
			kfree_rcu(vsi->xdp_rings[i], rcu);
			vsi->xdp_rings[i] = NULL;
		}
    ...
}

ice_unmap_xdp_rings() only restores the q_vector->tx.tx_ring pointers.
The clear_xdp_rings loop then frees only the ring struct.

ring->ring_stats is never freed on this path, and once the ring is gone
nothing points to it. ice_free_tx_ring() is never called either, so
tx_buf and desc stay on the devres list until the driver unbinds. Each
failed XDP attach or channel reconfiguration would add one more leak per
XDP Tx queue.

The normal teardown in ice_destroy_xdp_rings() calls ice_free_tx_ring(),
then kfree_rcu() on ring_stats, then kfree_rcu() on the ring. Could the
clear_xdp_rings label in ice_prepare_xdp_rings() do the same full
per-ring teardown instead?

That would cover the ice_cfg_vsi_lan() failure as well as both failure
points inside ice_xdp_alloc_setup_rings(). It would also make the
separate unwind in ice_xdp_alloc_setup_rings() unnecessary.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129055937.273668-1-lee%40jaeyeong.cc

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-30  6:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  5:59 [PATCH net] ice: fix XDP ring leaks on setup failures Jaeyeong Lee
2026-11-29  6:03 ` netdev-bot+sinfo
2026-11-29  8:03   ` Jaeyeong Lee
2026-11-30  6:02 ` 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