summaryrefslogtreecommitdiff
path: root/drivers/iommu/dmar.c
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2016-01-07 14:16:51 +0300
committerJoerg Roedel <jroedel@suse.de>2016-01-07 15:44:41 +0300
commitbc8474549e94efddb5d5791af0a015d13115b67b (patch)
tree082c049f62308c4eeb99d282fd507613f35be96c /drivers/iommu/dmar.c
parent592033790e8276f7038efb480871598648464a01 (diff)
downloadlinux-bc8474549e94efddb5d5791af0a015d13115b67b.tar.xz
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. Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/dmar.c')
-rw-r--r--drivers/iommu/dmar.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index add177a37f00..62a400c5ba06 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -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: