Skip to content

Commit 4daa861

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu: Fix error unwind in iommu_group_alloc()
If either iommu_group_grate_file() fails then the iommu_group is leaked. Destroy it on these error paths. Found by kselftest/iommu/iommufd_fail_nth Fixes: bc7d12b ("iommu: Implement reserved_regions iommu-group sysfs file") Fixes: c52c72d ("iommu: Add sysfs attribyte for domain type") Signed-off-by: Jason Gunthorpe <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 4762315 commit 4daa861

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iommu/iommu.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,12 +798,16 @@ struct iommu_group *iommu_group_alloc(void)
798798

799799
ret = iommu_group_create_file(group,
800800
&iommu_group_attr_reserved_regions);
801-
if (ret)
801+
if (ret) {
802+
kobject_put(group->devices_kobj);
802803
return ERR_PTR(ret);
804+
}
803805

804806
ret = iommu_group_create_file(group, &iommu_group_attr_type);
805-
if (ret)
807+
if (ret) {
808+
kobject_put(group->devices_kobj);
806809
return ERR_PTR(ret);
810+
}
807811

808812
pr_debug("Allocated group %d\n", group->id);
809813

0 commit comments

Comments
 (0)