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 73398459C6; Wed, 18 Sep 2024 09:54:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20FD942FA9; Wed, 18 Sep 2024 09:51:34 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id 30A3442EC7 for ; Wed, 18 Sep 2024 09:51:07 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id F0F2F1A13B8; Wed, 18 Sep 2024 09:51:06 +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 B85A81A1BE5; Wed, 18 Sep 2024 09:51:06 +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 390DD183C481; Wed, 18 Sep 2024 15:51:06 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Rohit Raj Subject: [v2 20/43] bus/fslmc: fix invalid error FD code Date: Wed, 18 Sep 2024 13:20:33 +0530 Message-Id: <20240918075056.1838654-21-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 Since error code was being set to 0 in case of error which is a valid fd, it caused memory leak issue. This issue have been fixed by changing zero to a valid non fd error. CID: 26661848 Signed-off-by: Rohit Raj --- drivers/bus/fslmc/fslmc_vfio.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 9a1e53f2ee..5b5fd2e6ca 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016-2023 NXP + * Copyright 2016-2024 NXP * */ @@ -41,8 +41,6 @@ #include "portal/dpaa2_hw_pvt.h" #include "portal/dpaa2_hw_dpio.h" -#define FSLMC_CONTAINER_MAX_LEN 8 /**< Of the format dprc.XX */ - #define FSLMC_VFIO_MP "fslmc_vfio_mp_sync" /* Container is composed by multiple groups, however, @@ -415,18 +413,16 @@ fslmc_vfio_open_group_fd(const char *group_name) mp_reply.nb_received == 1) { mp_rep = &mp_reply.msgs[0]; p = (struct vfio_mp_param *)mp_rep->param; - if (p->result == SOCKET_OK && mp_rep->num_fds == 1) { + if (p->result == SOCKET_OK && mp_rep->num_fds == 1) vfio_group_fd = mp_rep->fds[0]; - } else if (p->result == SOCKET_NO_FD) { + else if (p->result == SOCKET_NO_FD) DPAA2_BUS_ERR("Bad VFIO group fd"); - vfio_group_fd = 0; - } } free(mp_reply.msgs); add_vfio_group: - if (vfio_group_fd <= 0) { + if (vfio_group_fd < 0) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) { DPAA2_BUS_ERR("Open VFIO group(%s) failed(%d)", filename, vfio_group_fd); @@ -1802,14 +1798,11 @@ fslmc_vfio_setup_group(void) } vfio_group_fd = fslmc_vfio_group_fd_by_name(group_name); - if (vfio_group_fd <= 0) { + if (vfio_group_fd < 0) { vfio_group_fd = fslmc_vfio_open_group_fd(group_name); - if (vfio_group_fd <= 0) { + if (vfio_group_fd < 0) { DPAA2_BUS_ERR("%s: open group name(%s) failed(%d)", __func__, group_name, vfio_group_fd); - if (!vfio_group_fd) - close(vfio_group_fd); - DPAA2_BUS_ERR("Failed to create MC VFIO group"); return -rte_errno; } } -- 2.25.1