From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2A5D4459C6; Wed, 18 Sep 2024 09:53:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5629842F21; Wed, 18 Sep 2024 09:51:23 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id CED9442EBE for ; Wed, 18 Sep 2024 09:51:04 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B139A1A13B8; Wed, 18 Sep 2024 09:51:04 +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 786091A1BE5; Wed, 18 Sep 2024 09:51:04 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id D66C9183C480; Wed, 18 Sep 2024 15:51:03 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Rohit Raj Subject: [v2 15/43] bus/fslmc: free VFIO group FD in case of add group failure Date: Wed, 18 Sep 2024 13:20:28 +0530 Message-Id: <20240918075056.1838654-16-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240918075056.1838654-1-vanshika.shukla@nxp.com> References: <20240913055959.3246917-1-vanshika.shukla@nxp.com> <20240918075056.1838654-1-vanshika.shukla@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 From: Rohit Raj Free vfio_group_fd if add group fails to avoid ersource leak NXP coverity-id: 26661846 Signed-off-by: Rohit Raj --- drivers/bus/fslmc/fslmc_vfio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 15d2930cf0..45dac61d97 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -347,8 +347,10 @@ fslmc_vfio_open_group_fd(const char *group_name) } else { ret = fslmc_vfio_add_group(vfio_group_fd, iommu_group_num, group_name); - if (ret) + if (ret) { + close(vfio_group_fd); return ret; + } } return vfio_group_fd; @@ -1480,6 +1482,8 @@ fslmc_vfio_setup_group(void) if (vfio_group_fd <= 0) { vfio_group_fd = fslmc_vfio_open_group_fd(group_name); if (vfio_group_fd <= 0) { + if (!vfio_group_fd) + close(vfio_group_fd); DPAA2_BUS_ERR("Failed to create MC VFIO group"); return -rte_errno; } -- 2.25.1