From: Nicholas Krause <xerofoify@gmail.com>
Date: Mon, 4 Jan 2016 18:27:57 -0500
Subject: iommu/vt-d: Check the return value of iommu_device_create()
Git-commit: 592033790e8276f7038efb480871598648464a01
Patch-mainline: v4.5-rc1
References: fate#321026

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 the error code to the caller after freeing
up resources allocated previously.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/dmar.c | 6 ++++++
 1 file changed, 6 insertions(+)

--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1073,6 +1073,12 @@ static int alloc_iommu(struct dmar_drhd_
 						       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;
 
 err_unmap:
