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
  0 siblings, 1 reply; 2+ 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] 2+ messages in thread

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

Thread overview: 2+ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox