iommu/amd: Fix possible memory leak of 'domain'
Subsystems (2)
PATCH 1/1 iommu/amd: Fix possible memory leak of 'domain'
free memory of domain before return NULL.
--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +1 -1
@@ -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) {
Signature · 1 line
2.30.2
Quoted 4 lines · Su Hui
free memory of domain before return NULL.
Fixes 29f54745f245 ("iommu/amd: Add missing domain type checks")Signed-off-by Su Hui <[email protected]>
-Vasant
Quoted 17 lines
--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/iommu.c +1
-1@@ -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) {
Quoted 13 lines · Su Hui
free memory of domain before return NULL.
Fixes 29f54745f245 ("iommu/amd: Add missing domain type checks")Signed-off-by Su Hui <[email protected]>--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/iommu.c +0
-0
drivers/iommu/amd/iommu.c static struct protection_domain *protection_domain_alloc(unsigned int type) · line 2098
Quoted 6 lines
drivers/iommu/amd/iommu.c +1
-1@@ -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
Thanks,
Jason
Vasant Hegde
maintainerJason,
Quoted 24 lines · Jason Gunthorpe
Quoted 13 lines · Su Hui
free memory of domain before return NULL.
Fixes 29f54745f245 ("iommu/amd: Add missing domain type checks")Signed-off-by Su Hui <[email protected]>--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/iommu.c +0
-0drivers/iommu/amd/iommu.c static struct protection_domain *protection_domain_alloc(unsigned int type) · line 2098
Quoted 6 lines
drivers/iommu/amd/iommu.c +1
-1@@ -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
Quoted 1 line
This is fine too
Right. We are working on cleaning up/re-arranging this code path. Hopefully I will have patches soon.
-Vasant