From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Selwin Sebastian <selwin.sebastian@amd.com>,
Ravi Kumar <ravi1.kumar@amd.com>
Subject: [PATCH v2 2/4] net/axgbe: fix Rx queue leak on descriptor init failure
Date: Fri, 8 May 2026 12:10:50 -0700 [thread overview]
Message-ID: <20260508191109.734377-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20260508191109.734377-1-stephen@networkplumber.org>
When wrapper_rx_desc_init() fails to allocate an mbuf for queue i,
only queue i is released. Queues 0 through i-1 have already been
fully populated with mbufs assigned to sw_ring entries and
programmed into hardware descriptors, but are never cleaned up.
This leaks all mbufs from the previously initialized queues.
Fix by allocating all needed buffers ahead of time with
rte_pktmbuf_alloc_bulk() and on failure unwind the queues
that are already setup.
Fixes: 7c4158a5b592 ("net/axgbe: add DMA programming and start/stop")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/axgbe/axgbe_dev.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index 482d3d8062..9eabe0dfa8 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -1011,13 +1011,11 @@ static void wrapper_tx_desc_init(struct axgbe_port *pdata)
static int wrapper_rx_desc_init(struct axgbe_port *pdata)
{
- struct axgbe_rx_queue *rxq;
- struct rte_mbuf *mbuf;
volatile union axgbe_rx_desc *desc;
unsigned int i, j;
for (i = 0; i < pdata->eth_dev->data->nb_rx_queues; i++) {
- rxq = pdata->eth_dev->data->rx_queues[i];
+ struct axgbe_rx_queue *rxq = pdata->eth_dev->data->rx_queues[i];
/* Initialize software ring entries */
rxq->mbuf_alloc = 0;
@@ -1025,19 +1023,18 @@ static int wrapper_rx_desc_init(struct axgbe_port *pdata)
rxq->dirty = 0;
desc = AXGBE_GET_DESC_PT(rxq, 0);
+ if (!rte_pktmbuf_alloc_bulk(rxq->mb_pool, rxq->sw_ring, rxq->nb_desc)) {
+ PMD_DRV_LOG_LINE(ERR, "RX mbuf alloc failed queue_id = %u, nb_desc = %u",
+ i, rxq->nb_desc);
+ for (unsigned int k = 0; k < i; k++)
+ axgbe_dev_rx_queue_release(pdata->eth_dev, k);
+ return -ENOMEM;
+ }
+
for (j = 0; j < rxq->nb_desc; j++) {
- mbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
- if (mbuf == NULL) {
- PMD_DRV_LOG_LINE(ERR, "RX mbuf alloc failed queue_id = %u, idx = %d",
- (unsigned int)rxq->queue_id, j);
- axgbe_dev_rx_queue_release(pdata->eth_dev, i);
- return -ENOMEM;
- }
- rxq->sw_ring[j] = mbuf;
- /* Mbuf populate */
- mbuf->next = NULL;
- mbuf->data_off = RTE_PKTMBUF_HEADROOM;
- mbuf->nb_segs = 1;
+ struct rte_mbuf *mbuf = rxq->sw_ring[j];
+
+ /* mbuf is in reset state (nb_segs = 1, headroom, etc) */
mbuf->port = rxq->port_id;
desc->read.baddr =
rte_cpu_to_le_64(
--
2.53.0
next prev parent reply other threads:[~2026-05-08 19:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 16:40 [PATCH 0/4] net/axgbe: fix resource leaks and OOB access Stephen Hemminger
2026-02-18 16:40 ` [PATCH 1/4] net/axgbe: fix resource leaks in device init error paths Stephen Hemminger
2026-02-18 16:41 ` [PATCH 2/4] net/axgbe: fix Rx queue leak on descriptor init failure Stephen Hemminger
2026-04-05 16:11 ` Stephen Hemminger
2026-02-18 16:41 ` [PATCH 3/4] net/axgbe: destroy mutexes on device close Stephen Hemminger
2026-02-18 16:41 ` [PATCH 4/4] net/axgbe: fix descriptor status out-of-bounds access Stephen Hemminger
2026-02-20 17:50 ` [PATCH 0/4] net/axgbe: fix resource leaks and OOB access Stephen Hemminger
2026-02-25 16:52 ` Stephen Hemminger
2026-02-26 12:43 ` Sebastian, Selwin
2026-03-06 18:55 ` Stephen Hemminger
2026-03-08 16:53 ` Ande, Venkat Kumar
2026-03-11 10:53 ` Sebastian, Selwin
2026-05-08 19:10 ` [PATCH v2 " Stephen Hemminger
2026-05-08 19:10 ` [PATCH v2 1/4] net/axgbe: fix resource leaks in device init error paths Stephen Hemminger
2026-05-08 19:10 ` Stephen Hemminger [this message]
2026-05-08 19:10 ` [PATCH v2 3/4] net/axgbe: destroy mutexes on device close Stephen Hemminger
2026-05-08 19:10 ` [PATCH v2 4/4] net/axgbe: fix descriptor status out-of-bounds access Stephen Hemminger
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=20260508191109.734377-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=ravi1.kumar@amd.com \
--cc=selwin.sebastian@amd.com \
--cc=stable@dpdk.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