* [PATCH] iommu/amd: Fix possible memory leak of 'domain'
@ 2023-06-06 7:07 Su Hui
2023-06-07 4:19 ` Vasant Hegde
2023-06-07 14:22 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Su Hui @ 2023-06-06 7:07 UTC (permalink / raw)
To: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy
Cc: jgg, kevin.tian, vasant.hegde, iommu, linux-kernel, Su Hui
free memory of domain before return NULL.
Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
drivers/iommu/amd/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index dc1ec6849775..f08e65629c74 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2094,7 +2094,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
} else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
pgtable = amd_iommu_pgtable;
} else {
- return NULL;
+ goto out_err;
}
switch (pgtable) {
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/amd: Fix possible memory leak of 'domain'
2023-06-06 7:07 [PATCH] iommu/amd: Fix possible memory leak of 'domain' Su Hui
@ 2023-06-07 4:19 ` Vasant Hegde
2023-06-07 14:22 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Vasant Hegde @ 2023-06-07 4:19 UTC (permalink / raw)
To: Su Hui, Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy
Cc: jgg, kevin.tian, iommu, linux-kernel
On 6/6/2023 12:37 PM, Su Hui wrote:
> free memory of domain before return NULL.
>
> Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
> Signed-off-by: Su Hui <suhui@nfschina.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
> ---
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index dc1ec6849775..f08e65629c74 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2094,7 +2094,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
> } else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
> pgtable = amd_iommu_pgtable;
> } else {
> - return NULL;
> + goto out_err;
> }
>
> switch (pgtable) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/amd: Fix possible memory leak of 'domain'
2023-06-06 7:07 [PATCH] iommu/amd: Fix possible memory leak of 'domain' Su Hui
2023-06-07 4:19 ` Vasant Hegde
@ 2023-06-07 14:22 ` Jason Gunthorpe
2023-06-07 14:26 ` Vasant Hegde
1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2023-06-07 14:22 UTC (permalink / raw)
To: Su Hui
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
kevin.tian, vasant.hegde, iommu, linux-kernel
On Tue, Jun 06, 2023 at 03:07:42PM +0800, Su Hui wrote:
> free memory of domain before return NULL.
>
> Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index dc1ec6849775..f08e65629c74 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2094,7 +2094,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
> } else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
> pgtable = amd_iommu_pgtable;
> } else {
> - return NULL;
> + goto out_err;
> }
It might be nicer to order to allocation after the type checks, it is
more consistent with the other drivers
This is fine too
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Thanks,
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/amd: Fix possible memory leak of 'domain'
2023-06-07 14:22 ` Jason Gunthorpe
@ 2023-06-07 14:26 ` Vasant Hegde
0 siblings, 0 replies; 4+ messages in thread
From: Vasant Hegde @ 2023-06-07 14:26 UTC (permalink / raw)
To: Jason Gunthorpe, Su Hui
Cc: Joerg Roedel, Suravee Suthikulpanit, Will Deacon, Robin Murphy,
kevin.tian, iommu, linux-kernel
Jason,
On 6/7/2023 7:52 PM, Jason Gunthorpe wrote:
> On Tue, Jun 06, 2023 at 03:07:42PM +0800, Su Hui wrote:
>> free memory of domain before return NULL.
>>
>> Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
>> Signed-off-by: Su Hui <suhui@nfschina.com>
>> ---
>> drivers/iommu/amd/iommu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
>> index dc1ec6849775..f08e65629c74 100644
>> --- a/drivers/iommu/amd/iommu.c
>> +++ b/drivers/iommu/amd/iommu.c
>> @@ -2094,7 +2094,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
>> } else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
>> pgtable = amd_iommu_pgtable;
>> } else {
>> - return NULL;
>> + goto out_err;
>> }
>
> It might be nicer to order to allocation after the type checks, it is
> more consistent with the other drivers
>
> This is fine too
Right. We are working on cleaning up/re-arranging this code path.
Hopefully I will have patches soon.
-Vasant
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-07 14:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 7:07 [PATCH] iommu/amd: Fix possible memory leak of 'domain' Su Hui
2023-06-07 4:19 ` Vasant Hegde
2023-06-07 14:22 ` Jason Gunthorpe
2023-06-07 14:26 ` Vasant Hegde
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).