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 7E820CA5FF1 for ; Wed, 7 Oct 2026 07:25:17 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CA7641157; Wed, 7 Oct 2026 09:24:50 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 14A4F4027B; Wed, 7 Oct 2026 09:24:44 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id DA74E1A000C; Wed, 7 Oct 2026 09:24:43 +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 A56771A0018; Wed, 7 Oct 2026 09:24:43 +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 D069F1800243; Wed, 7 Oct 2026 15:24:42 +0800 (+08) From: Hemant Agrawal To: stephen@networkplumber.org, thomas@monjalon.net, dev@dpdk.org Cc: stable@dpdk.org Subject: [PATCH v22 03/27] net/dpaa: fix resource leak on probe failure Date: Wed, 7 Oct 2026 12:54:15 +0530 Message-Id: <20261007072439.3135351-4-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261007072439.3135351-1-hemant.agrawal@nxp.com> References: <20261006092703.2138929-1-hemant.agrawal@nxp.com> <20261007072439.3135351-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