* Re: [PATCH v2] iommu: Improve exception handling in iommu_group_alloc()
@ 2020-06-02 8:00 Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2020-06-02 8:00 UTC (permalink / raw)
To: Baolin Wang, Jörg Rödel, iommu
Cc: Kangjie Lu, kernel-janitors, linux-kernel, Qiushi Wu
> Improve the exception handling to free the resources correctly when
> failed to allocate an iommu group.
I propose to avoid the specification of duplicate function calls.
Will it become helpful to add a few jump targets?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=f359287765c04711ff54fbd11645271d8e5ff763#n455
> ---
> drivers/iommu/iommu.c | 10 ++++++++--
I suggest to replace the triple dashes before this diffstat
by a blank line.
Regards,
Markus
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2] iommu: Improve exception handling in iommu_group_alloc()
@ 2020-06-02 2:02 Baolin Wang
0 siblings, 0 replies; 2+ messages in thread
From: Baolin Wang @ 2020-06-02 2:02 UTC (permalink / raw)
To: joro; +Cc: iommu, linux-kernel, baolin.wang
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@linux.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
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-02 8:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 8:00 [PATCH v2] iommu: Improve exception handling in iommu_group_alloc() Markus Elfring
-- strict thread matches above, loose matches on Subject: below --
2020-06-02 2:02 Baolin Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).