From: Rolf Eike Beer Date: Tue, 25 May 2021 07:08:02 +0000 (+0800) Subject: iommu/vt-d: Fix sysfs leak in alloc_iommu() X-Git-Tag: v5.10.79~4164 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f01134321d04f47c718bb41b799bcdeda27873d2;p=platform%2Fkernel%2Flinux-rpi.git iommu/vt-d: Fix sysfs leak in alloc_iommu() commit 0ee74d5a48635c848c20f152d0d488bf84641304 upstream. iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent errors. Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device") Cc: stable@vger.kernel.org # 4.11.x Signed-off-by: Rolf Eike Beer Acked-by: Lu Baolu Link: https://lore.kernel.org/r/17411490.HIIP88n32C@mobilepool36.emlix.com Link: https://lore.kernel.org/r/20210525070802.361755-2-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 02e7c10..b8d0b56 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1137,7 +1137,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) err = iommu_device_register(&iommu->iommu); if (err) - goto err_unmap; + goto err_sysfs; } drhd->iommu = iommu; @@ -1145,6 +1145,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) return 0; +err_sysfs: + iommu_device_sysfs_remove(&iommu->iommu); err_unmap: unmap_iommu(iommu); error_free_seq_id: