From a7efb36d5945fe2f6f0980654551268bde3bb3b1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 2 Jul 2021 10:47:07 +0800 Subject: [PATCH] iommu/vt-d: Check for allocation failure in aux_detach_device() mainline inclusion from mainline-v5.13-rc4 commit 1a590a1c8bf46bf80ea12b657ca44c345531ac80 category: bugfix bugzilla: 108082 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1a590a1c8bf46bf80ea12b657ca44c345531ac80 ------------------------------------------------------------------------- In current kernels small allocations never fail, but checking for allocation failure is the correct thing to do. Fixes: 18abda7a2d55 ("iommu/vt-d: Fix general protection fault in aux_detach_device()") Signed-off-by: Dan Carpenter Acked-by: Lu Baolu Link: https://lore.kernel.org/r/YJuobKuSn81dOPLd@mwanda Link: https://lore.kernel.org/r/20210519015027.108468-2-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Zhen Lei Reviewed-by: Hanjun Guo Signed-off-by: Chen Jun Signed-off-by: Zheng Zengkai --- drivers/iommu/intel/iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 606c4f6f3d84..fe94013e9a62 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -5262,6 +5262,8 @@ static int auxiliary_link_device(struct dmar_domain *domain, if (!sinfo) { sinfo = kzalloc(sizeof(*sinfo), GFP_ATOMIC); + if (!sinfo) + return -ENOMEM; sinfo->domain = domain; sinfo->pdev = dev; list_add(&sinfo->link_phys, &info->subdevices); -- GitLab