* [PATCH] iommu: Fix error unwind in iommu_group_alloc()
@ 2023-02-16 1:21 Jason Gunthorpe
2023-02-16 2:38 ` Baolu Lu
2023-02-16 9:21 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2023-02-16 1:21 UTC (permalink / raw)
To: iommu, Joerg Roedel, Robin Murphy, Will Deacon
Cc: Bharat Bhushan, Eric Auger, Joerg Roedel, Olof Johansson,
Tomasz Nowicki, Will Deacon
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 <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index dd9b60897c8673..e41c9df1504ba3 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -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
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu: Fix error unwind in iommu_group_alloc()
2023-02-16 1:21 [PATCH] iommu: Fix error unwind in iommu_group_alloc() Jason Gunthorpe
@ 2023-02-16 2:38 ` Baolu Lu
2023-02-16 9:21 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Baolu Lu @ 2023-02-16 2:38 UTC (permalink / raw)
To: Jason Gunthorpe, iommu, Joerg Roedel, Robin Murphy, Will Deacon
Cc: baolu.lu, Bharat Bhushan, Eric Auger, Joerg Roedel,
Olof Johansson, Tomasz Nowicki, Will Deacon
On 2/16/23 9:21 AM, Jason Gunthorpe wrote:
> If either iommu_group_grate_file() fails then then the iommu_group
iommu_group_create_file()
> 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 <jgg@nvidia.com>
Other look good to me.
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
> ---
> drivers/iommu/iommu.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index dd9b60897c8673..e41c9df1504ba3 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu: Fix error unwind in iommu_group_alloc()
2023-02-16 1:21 [PATCH] iommu: Fix error unwind in iommu_group_alloc() Jason Gunthorpe
2023-02-16 2:38 ` Baolu Lu
@ 2023-02-16 9:21 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2023-02-16 9:21 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: iommu, Joerg Roedel, Robin Murphy, Will Deacon, Bharat Bhushan,
Eric Auger, Olof Johansson, Tomasz Nowicki, Will Deacon
On Wed, Feb 15, 2023 at 09:21:16PM -0400, Jason Gunthorpe wrote:
> 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 <jgg@nvidia.com>
> ---
> drivers/iommu/iommu.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-16 9:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 1:21 [PATCH] iommu: Fix error unwind in iommu_group_alloc() Jason Gunthorpe
2023-02-16 2:38 ` Baolu Lu
2023-02-16 9:21 ` Joerg Roedel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.