[PATCH v22 04/27] net/dpaa: fix free port resources on close

Hemant Agrawal hemant.agrawal at nxp.com
Wed Oct 7 09:24:16 CEST 2026


dpaa_intf->tx_conf_queues is allocated unconditionally for every port
in dpaa_dev_init():

	dpaa_intf->tx_conf_queues = rte_zmalloc(NULL,
		sizeof(struct qman_fq) * MAX_DPAA_CORES, MAX_CACHELINE);

but it is never released. It is a driver private allocation, so
rte_eth_dev_release_port() does not free it either. The memory is
therefore leaked on every device close and on every probe failure that
happens after the allocation.

dpaa_eth_dev_close() returned early for offline (O/H) and ONIC ports,
before the common cleanup that frees the queue and congestion-group
memory allocated at probe. Added support to clean that path as well.

Fixes: 58e0420f72f8 ("net/dpaa: support Tx confirmation to enable PTP")
Cc: stable at dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
 drivers/net/dpaa/dpaa_ethdev.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 2f6e2d20a3..1688acfb30 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -537,7 +537,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
 	if (fif->mac_type == fman_offline_internal ||
 	    fif->mac_type == fman_onic)
-		return 0;
+		goto clean_1;
 
 	/* Reset link to autoneg */
 	if (link->link_status && !link->link_autoneg) {
@@ -562,7 +562,7 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 				dev->data->name, ret);
 		}
 	}
-
+clean_1:
 	/* release configuration memory */
 	rte_free(dpaa_intf->fc_conf);
 
@@ -624,6 +624,9 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 		}
 	}
 
+	rte_free(dpaa_intf->tx_conf_queues);
+	dpaa_intf->tx_conf_queues = NULL;
+
 	return ret;
 }
 
@@ -2385,7 +2388,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
 	if (!dpaa_intf->tx_conf_queues) {
 		DPAA_PMD_ERR("Failed to alloc mem for TX conf queues");
 		ret = -ENOMEM;
-		goto free_rx;
+		goto free_tx;
 	}
 
 	/* If congestion control is enabled globally*/
@@ -2396,7 +2399,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
 		if (!dpaa_intf->cgr_tx) {
 			DPAA_PMD_ERR("Failed to alloc mem for cgr_tx");
 			ret = -ENOMEM;
-			goto free_rx;
+			goto free_tx;
 		}
 
 		ret = qman_alloc_cgrid_range(&cgrid_tx[0], MAX_DPAA_CORES,
@@ -2404,7 +2407,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
 		if (ret != MAX_DPAA_CORES) {
 			DPAA_PMD_WARN("insufficient CGRIDs available");
 			ret = -EINVAL;
-			goto free_rx;
+			goto free_tx;
 		}
 	} else {
 		dpaa_intf->cgr_tx = NULL;
@@ -2500,6 +2503,8 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
 	return 0;
 
 free_tx:
+	rte_free(dpaa_intf->tx_conf_queues);
+	dpaa_intf->tx_conf_queues = NULL;
 	rte_free(dpaa_intf->tx_queues);
 	dpaa_intf->tx_queues = NULL;
 	dpaa_intf->nb_tx_queues = 0;
-- 
2.25.1



More information about the dev mailing list