Skip to content

Commit 572f64c

Browse files
Zenghui YuAlex Williamson
authored andcommitted
vfio/type1: Use the new helper to find vfio_group
When attaching a new group to the container, let's use the new helper vfio_iommu_find_iommu_group() to check if it's already attached. There is no functional change. Also take this chance to add a missing blank line. Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 3cea11c commit 572f64c

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

drivers/vfio/vfio_iommu_type1.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,7 @@ static void vfio_iommu_iova_insert_copy(struct vfio_iommu *iommu,
19931993

19941994
list_splice_tail(iova_copy, iova);
19951995
}
1996+
19961997
static int vfio_iommu_type1_attach_group(void *iommu_data,
19971998
struct iommu_group *iommu_group)
19981999
{
@@ -2009,18 +2010,10 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
20092010

20102011
mutex_lock(&iommu->lock);
20112012

2012-
list_for_each_entry(d, &iommu->domain_list, next) {
2013-
if (find_iommu_group(d, iommu_group)) {
2014-
mutex_unlock(&iommu->lock);
2015-
return -EINVAL;
2016-
}
2017-
}
2018-
2019-
if (iommu->external_domain) {
2020-
if (find_iommu_group(iommu->external_domain, iommu_group)) {
2021-
mutex_unlock(&iommu->lock);
2022-
return -EINVAL;
2023-
}
2013+
/* Check for duplicates */
2014+
if (vfio_iommu_find_iommu_group(iommu, iommu_group)) {
2015+
mutex_unlock(&iommu->lock);
2016+
return -EINVAL;
20242017
}
20252018

20262019
group = kzalloc(sizeof(*group), GFP_KERNEL);

0 commit comments

Comments
 (0)