Skip to content

Commit 75b2774

Browse files
committed
iommu/amd: Free page-table in protection_domain_free()
Align release of the page-table with the place where it is allocated. Signed-off-by: Joerg Roedel <[email protected]> Reviewed-by: Suravee Suthikulpanit <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a71730e commit 75b2774

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,12 +2387,18 @@ static void cleanup_domain(struct protection_domain *domain)
23872387

23882388
static void protection_domain_free(struct protection_domain *domain)
23892389
{
2390+
struct domain_pgtable pgtable;
2391+
23902392
if (!domain)
23912393
return;
23922394

23932395
if (domain->id)
23942396
domain_id_free(domain->id);
23952397

2398+
amd_iommu_domain_get_pgtable(domain, &pgtable);
2399+
atomic64_set(&domain->pt_root, 0);
2400+
free_pagetable(&pgtable);
2401+
23962402
kfree(domain);
23972403
}
23982404

@@ -2476,7 +2482,6 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
24762482
static void amd_iommu_domain_free(struct iommu_domain *dom)
24772483
{
24782484
struct protection_domain *domain;
2479-
struct domain_pgtable pgtable;
24802485

24812486
domain = to_pdomain(dom);
24822487

@@ -2494,10 +2499,6 @@ static void amd_iommu_domain_free(struct iommu_domain *dom)
24942499
dma_ops_domain_free(domain);
24952500
break;
24962501
default:
2497-
amd_iommu_domain_get_pgtable(domain, &pgtable);
2498-
atomic64_set(&domain->pt_root, 0);
2499-
free_pagetable(&pgtable);
2500-
25012502
if (domain->flags & PD_IOMMUV2_MASK)
25022503
free_gcr3_table(domain);
25032504

0 commit comments

Comments
 (0)