From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1795ACA5FED for ; Fri, 9 Oct 2026 09:11:24 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D8494042E; Fri, 9 Oct 2026 11:11:09 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 1451F402D0; Fri, 9 Oct 2026 11:11:06 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id DA77D1A02D0; Fri, 9 Oct 2026 11:11:05 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id A57A31A02D4; Fri, 9 Oct 2026 11:11:05 +0200 (CEST) Received: from lsv03583.swis.in-blr01.nxp.com (lsv03583.swis.in-blr01.nxp.com [92.120.146.12]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id C936018000BA; Fri, 9 Oct 2026 17:11:04 +0800 (+08) From: Hemant Agrawal To: stephen@networkplumber.org, thomas@monjalon.net, dev@dpdk.org Cc: stable@dpdk.org Subject: [PATCH v23 03/27] net/dpaa: fix resource leak on probe failure Date: Fri, 9 Oct 2026 14:40:37 +0530 Message-Id: <20261009091101.1703494-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261009091101.1703494-1-hemant.agrawal@nxp.com> References: <20261007072439.3135351-1-hemant.agrawal@nxp.com> <20261009091101.1703494-1-hemant.agrawal@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When the shared Tx scatter-gather mempool cannot be created, rte_dpaa_probe() returns -ENOMEM directly: if (dpaa_tx_sg_pool == NULL) { DPAA_PMD_ERR("SG pool creation failed"); return -ENOMEM; } This is reached after dpaa_dev_init() has already succeeded, so the early return abandons everything set up for the port. Unwind through cleanup labels so the failure path closes the device and releases the port, matching the existing dpaa_dev_init() failure path. Fixes: 533c31cc8331 ("net/dpaa: use internal mempool for SG table") Cc: stable@dpdk.org Signed-off-by: Hemant Agrawal --- drivers/net/dpaa/dpaa_ethdev.c | 36 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 10b90417de..2f6e2d20a3 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -2602,24 +2602,30 @@ rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv, /* Invoke PMD device initialization function */ diag = dpaa_dev_init(eth_dev); - if (diag == 0) { - if (!dpaa_tx_sg_pool) { - dpaa_tx_sg_pool = - rte_pktmbuf_pool_create("dpaa_mbuf_tx_sg_pool", - DPAA_POOL_SIZE, - DPAA_POOL_CACHE_SIZE, 0, - DPAA_MAX_SGS * sizeof(struct qm_sg_entry), - rte_socket_id()); - if (dpaa_tx_sg_pool == NULL) { - DPAA_PMD_ERR("SG pool creation failed"); - return -ENOMEM; - } + if (diag != 0) + goto release_port; + + if (dpaa_tx_sg_pool == NULL) { + dpaa_tx_sg_pool = + rte_pktmbuf_pool_create("dpaa_mbuf_tx_sg_pool", + DPAA_POOL_SIZE, + DPAA_POOL_CACHE_SIZE, 0, + DPAA_MAX_SGS * sizeof(struct qm_sg_entry), + rte_socket_id()); + if (dpaa_tx_sg_pool == NULL) { + DPAA_PMD_ERR("SG pool creation failed"); + diag = -ENOMEM; + goto close_dev; } - rte_eth_dev_probing_finish(eth_dev); - dpaa_valid_dev++; - return 0; } + rte_eth_dev_probing_finish(eth_dev); + dpaa_valid_dev++; + return 0; + +close_dev: + dpaa_eth_dev_close(eth_dev); +release_port: rte_eth_dev_release_port(eth_dev); return diag; } -- 2.25.1