iommu:Check that iommu_device_create has completed successfully in alloc_iommu
PATCH 1/1 iommu:Check that iommu_device_create has completed successfully in alloc_iommu
This adds the proper check to alloc_iommu to make sure that the call to iommu_device_create has completed successfully and if not return to the caller the error code returned after freeing up resources allocated previously by alloc_iommu.
--- drivers/iommu/dmar.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iommu/dmar.c +6 -0
@@ -1069,6 +1069,12 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) iommu->iommu_dev =iommu_device_create (NULL , iommu, intel_iommu_groups,"%s" , iommu->name); + +if (IS_ERR (iommu->iommu_dev)) { + drhd->iommu =NULL ; + err =PTR_ERR (iommu->iommu_dev); + goto err_unmap; + }return 0 ;
Signature · 1 line
2.5.0
Joerg Roedel
maintainerPATCH 1/1 iommu/vt-d: Fix up error handling in alloc_iommu successfully in alloc_iommu
Quoted 6 lines · Nicholas Krause
This adds the proper check to
alloc_iommuto make sure that the call toiommu_device_createhas completed successfully and if not return to the caller the error code returned after freeing up resources allocated previously byalloc_iommu.Signed-off-by Nicholas Krause <[email protected]>
Applied with this fixup on top:
Quoted 1 line
From
3108f03ce20adf6429cb130b44da528ae85fc68dMon Sep 17 00:00:00 2001
From: Joerg Roedel <[email protected]>
Date: Thu, 7 Jan 2016 12:16:51 +0100
Subject: [PATCH] iommu/vt-d: Fix up error handling in alloc_iommu
Only check for error when iommu->iommu_dev has been assigned and only assign drhd->iommu when the function can't fail anymore.
--- drivers/iommu/dmar.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iommu/dmar.c +7 -7
@@ -1063,19 +1063,19 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)raw_spin_lock_init (&iommu->register_lock); - drhd->iommu = iommu; - -if (intel_iommu_enabled) +if (intel_iommu_enabled) { iommu->iommu_dev =iommu_device_create (NULL , iommu, intel_iommu_groups,"%s" , iommu->name); -if (IS_ERR (iommu->iommu_dev)) { - drhd->iommu =NULL ; - err =PTR_ERR (iommu->iommu_dev); - goto err_unmap; +if (IS_ERR (iommu->iommu_dev)) { + err =PTR_ERR (iommu->iommu_dev); + goto err_unmap; + } } + drhd->iommu = iommu; +return 0 ; err_unmap:
Signature · 1 line
1.8.4.5