From: Jason Gunthorpe Date: Tue, 10 Sep 2024 20:00:34 +0000 (-0300) Subject: iommu/amd: Test for PAGING domains before freeing a domain X-Git-Tag: v6.12-rc1~149^2^4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ab9d8d1b50b516507655b10e19d8e624ad1d79c;p=thirdparty%2Flinux.git iommu/amd: Test for PAGING domains before freeing a domain This domain free function can be called for IDENTITY and SVA domains too, and they don't have page tables. For now protect against this by checking the type. Eventually the different types should have their own free functions. Fixes: 485534bfccb2 ("iommu/amd: Remove conditions from domain free paths") Reported-by: Vasant Hegde Signed-off-by: Jason Gunthorpe Reviewed-by: Vasant Hegde Link: https://lore.kernel.org/r/0-v1-ad9884ee5f5b+da-amd_iopgtbl_fix_jgg@nvidia.com Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 2876ac42ae2d4..f4dfabb3e14d3 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2254,7 +2254,8 @@ static void cleanup_domain(struct protection_domain *domain) void protection_domain_free(struct protection_domain *domain) { WARN_ON(!list_empty(&domain->dev_list)); - free_io_pgtable_ops(&domain->iop.pgtbl.ops); + if (domain->domain.type & __IOMMU_DOMAIN_PAGING) + free_io_pgtable_ops(&domain->iop.pgtbl.ops); domain_id_free(domain->id); kfree(domain); }