The fd opened to read the iommu_group link of the device is closed on every path except the one that finds the group already open, so every device after the first one in a group leaked an fd. Return through the goto on that path too. Signed-off-by: Mostafa Saleh --- vfio/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vfio/core.c b/vfio/core.c index fbe0098..e0c56ab 100644 --- a/vfio/core.c +++ b/vfio/core.c @@ -544,7 +544,7 @@ vfio_group_get_for_dev(struct kvm *kvm, struct vfio_device *vdev) list_for_each_entry(group, &vfio_groups, list) { if (group->id == group_id) { group->refs++; - return group; + goto out_close; } } -- 2.56.0.307.g5fe7bd680c-goog