[PATCH v5 02/35] net/intel: fix memory leak on TX queue setup failure

Bruce Richardson
2026-02-11T18:13:41Z

When TX queue setup fails after sw_ring allocation but during
completion queue setup, the allocated sw_ring memory is not freed,
causing a memory leak.

This patch adds the missing rte_free() call in the error path for
both cpfl and idpf drivers to properly clean up sw_ring before
returning from the function.

Fixes: 6c2d333cd418 ("net/cpfl: support Tx queue setup")
Fixes: c008a5e740bd ("common/idpf: add queue setup/release")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/cpfl/cpfl_rxtx.c | 1 +
drivers/net/intel/idpf/idpf_rxtx.c | 1 +
2 files changed, 2 insertions(+)

diff --git a/drivers/net/intel/cpfl/cpfl_rxtx.c b/drivers/net/intel/cpfl/cpfl_rxtx.c
index 78bc3e9b49..392a7fcc98 100644
--- a/drivers/net/intel/cpfl/cpfl_rxtx.c
+++ b/drivers/net/intel/cpfl/cpfl_rxtx.c
@@ -628,6 +628,7 @@ cpfl_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
return 0;

err_complq_setup:
+ rte_free(txq->sw_ring);
err_sw_ring_alloc:
cpfl_dma_zone_release(mz);
err_mz_reserve:
diff --git a/drivers/net/intel/idpf/idpf_rxtx.c b/drivers/net/intel/idpf/idpf_rxtx.c
index 8aa44585fe..9317c8b175 100644
--- a/drivers/net/intel/idpf/idpf_rxtx.c
+++ b/drivers/net/intel/idpf/idpf_rxtx.c
@@ -502,6 +502,7 @@ idpf_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
return 0;

err_complq_setup:
+ rte_free(txq->sw_ring);
err_sw_ring_alloc:
idpf_dma_zone_release(mz);
err_mz_reserve:
--
2.51.0