diff options
author | Jason Gunthorpe <[email protected]> | 2023-02-15 21:21:16 -0400 |
---|---|---|
committer | Joerg Roedel <[email protected]> | 2023-02-16 10:20:31 +0100 |
commit | 4daa861174d56023c2068ddb03de0752f07fa199 (patch) | |
tree | 678a273aa30aecd4755f4042488b43a52ab0b278 | |
parent | 4762315d1c971312d55848fdc85eee7f0b09c8f2 (diff) |
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: 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]>
Reviewed-by: Lu Baolu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
-rw-r--r-- | drivers/iommu/iommu.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 42591766266d..989c0c963be3 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -798,12 +798,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); |