Skip to content

Commit f78947c

Browse files
Jon Derrickjoergroedel
authored andcommitted
iommu/vt-d: Unlink device if failed to add to group
If the device fails to be added to the group, make sure to unlink the reference before returning. Signed-off-by: Jon Derrick <[email protected]> Fixes: 39ab955 ("iommu: Add sysfs bindings for struct iommu_device") Acked-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 7d4e6cc commit f78947c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5624,8 +5624,10 @@ static int intel_iommu_add_device(struct device *dev)
56245624

56255625
group = iommu_group_get_for_dev(dev);
56265626

5627-
if (IS_ERR(group))
5628-
return PTR_ERR(group);
5627+
if (IS_ERR(group)) {
5628+
ret = PTR_ERR(group);
5629+
goto unlink;
5630+
}
56295631

56305632
iommu_group_put(group);
56315633

@@ -5651,7 +5653,8 @@ static int intel_iommu_add_device(struct device *dev)
56515653
if (!get_private_domain_for_dev(dev)) {
56525654
dev_warn(dev,
56535655
"Failed to get a private domain.\n");
5654-
return -ENOMEM;
5656+
ret = -ENOMEM;
5657+
goto unlink;
56555658
}
56565659

56575660
dev_info(dev,
@@ -5666,6 +5669,10 @@ static int intel_iommu_add_device(struct device *dev)
56665669
}
56675670

56685671
return 0;
5672+
5673+
unlink:
5674+
iommu_device_unlink(&iommu->iommu, dev);
5675+
return ret;
56695676
}
56705677

56715678
static void intel_iommu_remove_device(struct device *dev)

0 commit comments

Comments
 (0)