iommu: Fix error unwind in iommu_group_alloc()
PATCH 1/1 iommu: Fix error unwind in iommu_group_alloc()
If either iommu_group_grate_file() fails then then the iommu_group is leaked.
Destroy it on these error paths.
Found by kselftest/iommu/iommufd_fail_nth
Fixes bc7d12b91bd3 ("iommu: Implement reserved_regions iommu-group sysfs file")
Fixes c52c72d3dee8 ("iommu: Add sysfs attribyte for domain type")
Signed-off-by Jason Gunthorpe <[email protected]>
--- drivers/iommu/iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iommu/iommu.c +6 -2
@@ -775,12 +775,16 @@ struct iommu_group *iommu_group_alloc(void) ret =iommu_group_create_file (group, &iommu_group_attr_reserved_regions); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + } ret =iommu_group_create_file (group, &iommu_group_attr_type); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + }pr_debug ("Allocated group %d\n" , group->id);
base-commit: c643eb52cb7c1f6747ddc60d8a187a3ca0746a12
Signature · 1 line
2.39.1
Quoted 1 line · Jason Gunthorpe
If either
iommu_group_grate_file()fails then then theiommu_group
iommu_group_create_file()
Quoted 9 lines
is leaked.
Destroy it on these error paths.
Found by kselftest/iommu/iommufd_fail_nth
Fixes bc7d12b91bd3 ("iommu: Implement reserved_regions iommu-group sysfs file")Fixes c52c72d3dee8 ("iommu: Add sysfs attribyte for domain type")Signed-off-by Jason Gunthorpe <[email protected]>
Other look good to me.
Reviewed-by Lu Baolu <[email protected]>
Best regards,
baolu
Quoted 29 lines
--- drivers/iommu/iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/iommu/iommu.c +6
-2@@ -775,12 +775,16 @@ struct iommu_group *iommu_group_alloc(void) ret =iommu_group_create_file (group, &iommu_group_attr_reserved_regions); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + } ret =iommu_group_create_file (group, &iommu_group_attr_type); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + }pr_debug ("Allocated group %d\n" , group->id);base-commit:
c643eb52cb7c1f6747ddc60d8a187a3ca0746a12
Joerg Roedel
AppliedQuoted 5 lines · Jason Gunthorpe
If either
iommu_group_grate_file()fails then then theiommu_groupis leaked.Destroy it on these error paths.
Quoted 8 lines
Found by kselftest/iommu/iommufd_fail_nth
Fixes bc7d12b91bd3 ("iommu: Implement reserved_regions iommu-group sysfs file")Fixes c52c72d3dee8 ("iommu: Add sysfs attribyte for domain type")Signed-off-by Jason Gunthorpe <[email protected]>--- drivers/iommu/iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Applied, thanks.