summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Snitselaar <jsnitsel@redhat.com>2022-10-19 08:44:47 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-11-03 23:52:26 +0900
commit5cecfe151874b835331efe086bbdcaeaf64f6b90 (patch)
treec6dfe714751336a1b779761e07ef27ee7a3be6bc
parent7ae1345f6ad715acbcdc9e1ac28153684fd498bb (diff)
downloadlinux-stable-5cecfe151874b835331efe086bbdcaeaf64f6b90.tar.gz
linux-stable-5cecfe151874b835331efe086bbdcaeaf64f6b90.tar.bz2
linux-stable-5cecfe151874b835331efe086bbdcaeaf64f6b90.zip
iommu/vt-d: Clean up si_domain in the init_dmars() error path
[ Upstream commit 620bf9f981365c18cc2766c53d92bf8131c63f32 ] A splat from kmem_cache_destroy() was seen with a kernel prior to commit ee2653bbe89d ("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: 86080ccc223a ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/iommu/intel-iommu.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index dcb865d19309..1b25f5c0dfad 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2800,6 +2800,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;
}
@@ -3502,6 +3503,10 @@ free_iommu:
disable_dmar_iommu(iommu);
free_dmar_iommu(iommu);
}
+ if (si_domain) {
+ domain_exit(si_domain);
+ si_domain = NULL;
+ }
kfree(g_iommus);