> @@ -775,12 +776,7 @@ static struct vfio_group *vfio_group_find_or_alloc(struct device *dev) > if (group) > goto out_put; > > - /* a newly created vfio_group keeps the reference. */ > group = vfio_create_group(iommu_group, VFIO_IOMMU); > - if (IS_ERR(group)) > - goto out_put; > - return group; > - > out_put: > iommu_group_put(iommu_group); > return group; I'd simplify this down to: group = vfio_group_get_from_iommu(iommu_group); if (!group) group = vfio_create_group(iommu_group, VFIO_IOMMU); but otherwise this looks good: Reviewed-by: Christoph Hellwig <hch@xxxxxx>