Skip to content

Commit

Permalink
iommu/vt-d: Fix sysfs leak in alloc_iommu()
Browse files Browse the repository at this point in the history
commit 0ee74d5 upstream.

iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent
errors.

Fixes: 39ab955 ("iommu: Add sysfs bindings for struct iommu_device")
Cc: stable@vger.kernel.org # 4.11.x
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
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 <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
DerDakon authored and gregkh committed Jun 3, 2021
1 parent f989065 commit f011343
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/iommu/intel/dmar.c
Expand Up @@ -1137,14 +1137,16 @@ 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;
iommu->drhd = drhd;

return 0;

err_sysfs:
iommu_device_sysfs_remove(&iommu->iommu);
err_unmap:
unmap_iommu(iommu);
error_free_seq_id:
Expand Down

0 comments on commit f011343

Please sign in to comment.