[PATCH 2/4] net/axgbe: fix Rx queue leak on descriptor init failure

Stephen Hemminger
2026-02-18T16:43:41Z

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 releasing all previously initialized queues when an
allocation failure occurs.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/axgbe/axgbe_dev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c
index 634d4ee4a5..ae2ae42021 100644
--- a/drivers/net/axgbe/axgbe_dev.c
+++ b/drivers/net/axgbe/axgbe_dev.c
@@ -1025,7 +1025,10 @@ static int wrapper_rx_desc_init(struct axgbe_port *pdata)
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);
+
+ do {
+ axgbe_dev_rx_queue_release(pdata->eth_dev, i);
+ } while (i-- > 0);
return -ENOMEM;
}
rxq->sw_ring[j] = mbuf;
--
2.51.0