mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Fix memory leak when domain type checks fail
@ 2023-06-12  2:17 Hao Ge
  2023-06-14  7:36 ` Vasant Hegde
  0 siblings, 1 reply; 2+ messages in thread
From: Hao Ge @ 2023-06-12  2:17 UTC (permalink / raw)
  To: joro, suravee.suthikulpanit, will, robin.murphy
  Cc: kevin.tian, jgg, vasant.hegde, iommu, linux-kernel, gehao618, Hao Ge

When domain type checks fail,we also should free protection_domain struct
to avoid memory leak in protection_domain_alloc

Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
 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.25.1


No virus found
		Checked by Hillstone Network AntiVirus

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/amd: Fix memory leak when domain type checks fail
  2023-06-12  2:17 [PATCH] iommu/amd: Fix memory leak when domain type checks fail Hao Ge
@ 2023-06-14  7:36 ` Vasant Hegde
  0 siblings, 0 replies; 2+ messages in thread
From: Vasant Hegde @ 2023-06-14  7:36 UTC (permalink / raw)
  To: Hao Ge, joro, suravee.suthikulpanit, will, robin.murphy
  Cc: kevin.tian, jgg, iommu, linux-kernel, gehao618

Hi,

On 6/12/2023 7:47 AM, Hao Ge wrote:
> When domain type checks fail,we also should free protection_domain struct
> to avoid memory leak in protection_domain_alloc
> 

There is another patch from Su to fix this issue [1].

[1] https://lore.kernel.org/linux-iommu/20230608021933.856045-1-suhui@nfschina.com/

-Vasant

> Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---
>  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] 2+ messages in thread

end of thread, other threads:[~2023-06-14  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12  2:17 [PATCH] iommu/amd: Fix memory leak when domain type checks fail Hao Ge
2023-06-14  7:36 ` Vasant Hegde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®