From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 17A68A04B5 for ; Fri, 11 Sep 2020 13:08:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF8D51C0D9; Fri, 11 Sep 2020 13:08:16 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id C3BC8E07; Fri, 11 Sep 2020 13:08:13 +0200 (CEST) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1BE24E24009D78D146B4; Fri, 11 Sep 2020 19:08:12 +0800 (CST) Received: from localhost (10.174.185.168) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Fri, 11 Sep 2020 19:08:06 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Fri, 11 Sep 2020 19:08:04 +0800 Message-ID: <1599822484-19100-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <20200621090800.1AE521C00D@dpdk.org> References: <20200621090800.1AE521C00D@dpdk.org> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.185.168] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [dpdk-dev] [PATCH v2 RESEND] vfio: fix resource leak when mapping fails X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Yunjian Wang Currently, only the 'vfio_dev_fd' is closed in failure path, so some resources are not released(such as 'vfio_group_fd'). The rte_vfio_release_device() should be used to avoid this problem. Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- v2: Update email address --- drivers/bus/pci/linux/pci_vfio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index c15ed3bad..17350f34d 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -826,7 +826,8 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) err_vfio_res: rte_free(vfio_res); err_vfio_dev_fd: - close(vfio_dev_fd); + rte_vfio_release_device(rte_pci_get_sysfs_path(), + pci_addr, vfio_dev_fd); return -1; } @@ -894,7 +895,8 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev) return 0; err_vfio_dev_fd: - close(vfio_dev_fd); + rte_vfio_release_device(rte_pci_get_sysfs_path(), + pci_addr, vfio_dev_fd); return -1; } -- 2.23.0