vfio: fix race condition with sysfs
authorMichael Haeuptle <michael.haeuptle@hpe.com>
Mon, 6 Apr 2020 22:23:23 +0000 (22:23 +0000)
committerDavid Marchand <david.marchand@redhat.com>
Tue, 21 Apr 2020 16:13:44 +0000 (18:13 +0200)
commitb758423bc4fe412941a289f3181849669c02b904
treeda65a9702fdab53447228edeea1f942b619c9c6a
parent9b41c276fd35fe3c0ed3fb0d9cf98a83a58b31b2
vfio: fix race condition with sysfs

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: 340b7bb8d583 ("vfio: extend data structure for multi container")
Cc: stable@dpdk.org
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>
lib/librte_eal/linux/eal_vfio.c