From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>
Cc: baolu.lu@linux.intel.com, Bharat Bhushan <bharat.bhushan@nxp.com>,
Eric Auger <eric.auger@redhat.com>,
Joerg Roedel <jroedel@suse.de>, Olof Johansson <olof@lixom.net>,
Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>,
Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH] iommu: Fix error unwind in iommu_group_alloc()
Date: Thu, 16 Feb 2023 10:38:11 +0800 [thread overview]
Message-ID: <1cf45b73-1685-5eea-a894-8282eea019ac@linux.intel.com> (raw)
In-Reply-To: <0-v1-8f616bee028d+8b-iommu_group_alloc_leak_jgg@nvidia.com>
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
next prev parent reply other threads:[~2023-02-16 2:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 1:21 [PATCH] iommu: Fix error unwind in iommu_group_alloc() Jason Gunthorpe
2023-02-16 2:38 ` Baolu Lu [this message]
2023-02-16 9:21 ` Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1cf45b73-1685-5eea-a894-8282eea019ac@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=bharat.bhushan@nxp.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=olof@lixom.net \
--cc=robin.murphy@arm.com \
--cc=tomasz.nowicki@caviumnetworks.com \
--cc=will.deacon@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox