Skip to content

Commit

Permalink
vfio: fix race condition with sysfs
Browse files Browse the repository at this point in the history
[ upstream commit b758423 ]

This fix treats a 0 return value from vfio_open_group_fd
in vfio_get_group_fd as the intended error condition instead
of putting an incorrect 0 file descriptor in the vfio_group table.

Sometimes, the creation of device files in sysfs is not
instantaneously causing vfio_open_groupfd to return 0.
This has been observed when hot removing/adding multiple
NVMe devices (>=4).

Fixes: 340b7bb ("vfio: extend data structure for multi container")

Signed-off-by: Michael Haeuptle <michael.haeuptle@hpe.com>
Acked-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
Michael Haeuptle authored and kevintraynor committed May 27, 2020
1 parent 4d3460a commit 7deb7d4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/librte_eal/linuxapp/eal/eal_vfio.c
Expand Up @@ -378,7 +378,7 @@ vfio_get_group_fd(struct vfio_config *vfio_cfg,
}

vfio_group_fd = vfio_open_group_fd(iommu_group_num);
if (vfio_group_fd < 0) {
if (vfio_group_fd <= 0) {
RTE_LOG(ERR, EAL, "Failed to open group %d\n", iommu_group_num);
return -1;
}
Expand Down

0 comments on commit 7deb7d4

Please sign in to comment.