From: Yunjian Wang Date: Fri, 11 Sep 2020 11:08:04 +0000 (+0800) Subject: bus/pci: fix leak on VFIO mapping error X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2a089d2d52f45bca6f179345fa3f3abe1a0e2ea9;p=dpdk.git bus/pci: fix leak on VFIO mapping error 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 Reviewed-by: Anatoly Burakov --- diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index 940ebc1e35..ef4f72017f 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -838,7 +838,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; } @@ -906,7 +907,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; }