From: Nicholas Krause Subject: [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu Date: Tue, 29 Dec 2015 00:10:11 -0500 Message-ID: <1451365811-19111-1-git-send-email-xerofoify@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: iommu@lists.linux-foundation.org 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. Signed-off-by: Nicholas Krause --- drivers/iommu/dmar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 80e3c17..27333b6 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1069,9 +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)) { + err = PTR_ERR(iommu->iommu_dev); + goto err_unmap; + } return 0; - err_unmap: unmap_iommu(iommu); error_free_seq_id: -- 2.5.0