[<prev] [next>] [day] [month] [year] [list]
Message-Id: <8bfd018ef4add083a35a6a94a8da045cf3af51b6.1591063271.git.baolin.wang@linux.alibaba.com>
Date: Tue, 2 Jun 2020 10:02:23 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: joro@...tes.org
Cc: baolin.wang@...ux.alibaba.com, iommu@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] iommu: Improve exception handling in iommu_group_alloc()
Improve the exception handling to free the resources correctly when
failed to allocate an iommu group.
Fixes: bc7d12b91bd3 ("iommu: Implement reserved_regions iommu-group sysfs file")
Signed-off-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
---
Changes from v1:
- Improve the commmit message.
- Add Fixes tag.
---
drivers/iommu/iommu.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 03d6a26..ac91024 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -529,12 +529,18 @@ 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) {
+ iommu_group_remove_file(group,
+ &iommu_group_attr_reserved_regions);
+ kobject_put(group->devices_kobj);
return ERR_PTR(ret);
+ }
pr_debug("Allocated group %d\n", group->id);
--
1.8.3.1
Powered by blists - more mailing lists