From 4b10ae80272b1bec113fbf5848065b66f030c327 Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Tue, 19 May 2020 11:42:12 +0800 Subject: [PATCH] bus/fslmc: fix VFIO group descriptor check The issue is that a file descriptor at 0 is a valid one. Currently the file not found, the return value will be set to 0. As a result, it is impossible to distinguish between a correct descriptor and a failed return value. Fix it to return -ENOENT instead of 0. Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Anatoly Burakov Acked-by: Hemant Agrawal --- drivers/bus/fslmc/fslmc_vfio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 9134ec5527..2e1803a185 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -457,11 +457,14 @@ fslmc_vfio_setup_device(const char *sysfs_base, const char *dev_addr, /* get the actual group fd */ vfio_group_fd = rte_vfio_get_group_fd(iommu_group_no); - if (vfio_group_fd < 0) + if (vfio_group_fd < 0 && vfio_group_fd != -ENOENT) return -1; - /* if group_fd == 0, that means the device isn't managed by VFIO */ - if (vfio_group_fd == 0) { + /* + * if vfio_group_fd == -ENOENT, that means the device + * isn't managed by VFIO + */ + if (vfio_group_fd == -ENOENT) { RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, skipping\n", dev_addr); return 1; -- 2.20.1