mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
UPSTREAM: iommu/amd: Fix possible memory leak of 'domain'
Move allocation code down to avoid memory leak. Bug: 254441685 Fixes:29f54745f2("iommu/amd: Add missing domain type checks") Signed-off-by: Su Hui <suhui@nfschina.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> Link: https://lore.kernel.org/r/20230608021933.856045-1-suhui@nfschina.com Signed-off-by: Joerg Roedel <jroedel@suse.de> (cherry picked from commit5b00369fcf) Signed-off-by: Lee Jones <joneslee@google.com> Change-Id: If78fac206bfdc899bed14335ed46eda3946591a2
This commit is contained in:
@@ -2055,10 +2055,6 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
|
|||||||
int mode = DEFAULT_PGTABLE_LEVEL;
|
int mode = DEFAULT_PGTABLE_LEVEL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
domain = kzalloc(sizeof(*domain), GFP_KERNEL);
|
|
||||||
if (!domain)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Force IOMMU v1 page table when iommu=pt and
|
* Force IOMMU v1 page table when iommu=pt and
|
||||||
* when allocating domain for pass-through devices.
|
* when allocating domain for pass-through devices.
|
||||||
@@ -2074,6 +2070,10 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
domain = kzalloc(sizeof(*domain), GFP_KERNEL);
|
||||||
|
if (!domain)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
switch (pgtable) {
|
switch (pgtable) {
|
||||||
case AMD_IOMMU_V1:
|
case AMD_IOMMU_V1:
|
||||||
ret = protection_domain_init_v1(domain, mode);
|
ret = protection_domain_init_v1(domain, mode);
|
||||||
|
|||||||
Reference in New Issue
Block a user