]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iommu/vt-d: Clean up si_domain in the init_dmars() error path
authorJerry Snitselaar <jsnitsel@redhat.com>
Wed, 19 Oct 2022 00:44:47 +0000 (08:44 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 21 Oct 2022 08:49:35 +0000 (10:49 +0200)
A splat from kmem_cache_destroy() was seen with a kernel prior to
commit a08ebdc5824e ("iommu/vt-d: Remove domain and devinfo mempool")
when there was a failure in init_dmars(), because the iommu_domain
cache still had objects. While the mempool code is now gone, there
still is a leak of the si_domain memory if init_dmars() fails. So
clean up si_domain in the init_dmars() error path.

Cc: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Will Deacon <will@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Fixes: 965666c5930a ("iommu/vt-d: Allocate si_domain in init_dmars()")
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Link: https://lore.kernel.org/r/20221010144842.308890-1-jsnitsel@redhat.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/iommu.c

index b3cf0f991e29744b61ed33afde6de609f7ee7b85..48cdcd0a5cf346fe8136b35ebd12b65d5546fde8 100644 (file)
@@ -2410,6 +2410,7 @@ static int __init si_domain_init(int hw)
 
        if (md_domain_init(si_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) {
                domain_exit(si_domain);
+               si_domain = NULL;
                return -EFAULT;
        }
 
@@ -3052,6 +3053,10 @@ free_iommu:
                disable_dmar_iommu(iommu);
                free_dmar_iommu(iommu);
        }
+       if (si_domain) {
+               domain_exit(si_domain);
+               si_domain = NULL;
+       }
 
        return ret;
 }