Netdev List
 help / color / mirror / Atom feed
From: Jaeyeong Lee <lee@jaeyeong.cc>
To: Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, Jaeyeong Lee <lee@jaeyeong.cc>,
	stable@vger.kernel.org
Subject: [PATCH net] ice: fix XDP ring leaks on setup failures
Date: Sun, 29 Nov 2026 05:59:44 +0000	[thread overview]
Message-ID: <20261129055937.273668-1-lee@jaeyeong.cc> (raw)

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



             reply	other threads:[~2026-11-29  5:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  5:59 Jaeyeong Lee [this message]
2026-11-29  6:03 ` [PATCH net] ice: fix XDP ring leaks on setup failures netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261129055937.273668-1-lee@jaeyeong.cc \
    --to=lee@jaeyeong.cc \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox