From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: [PATCH] iommu/vt-d: Fix up error handling in alloc_iommu successfully in alloc_iommu Date: Thu, 7 Jan 2016 12:19:22 +0100 Message-ID: <20160107111922.GA19149@8bytes.org> References: <1451950077-22025-1-git-send-email-xerofoify@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1451950077-22025-1-git-send-email-xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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: Nicholas Krause Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: iommu@lists.linux-foundation.org On Mon, Jan 04, 2016 at 06:27:57PM -0500, Nicholas Krause wrote: > 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 Applied with this fixup on top: >>From 3108f03ce20adf6429cb130b44da528ae85fc68d Mon Sep 17 00:00:00 2001 From: Joerg Roedel 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. Signed-off-by: Joerg Roedel --- drivers/iommu/dmar.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index add177a..62a400c 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: -- 1.8.4.5 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752900AbcAGLTg (ORCPT ); Thu, 7 Jan 2016 06:19:36 -0500 Received: from 8bytes.org ([81.169.241.247]:50139 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752018AbcAGLTc (ORCPT ); Thu, 7 Jan 2016 06:19:32 -0500 Date: Thu, 7 Jan 2016 12:19:22 +0100 From: Joerg Roedel To: Nicholas Krause Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/vt-d: Fix up error handling in alloc_iommu successfully in alloc_iommu Message-ID: <20160107111922.GA19149@8bytes.org> References: <1451950077-22025-1-git-send-email-xerofoify@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1451950077-22025-1-git-send-email-xerofoify@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 04, 2016 at 06:27:57PM -0500, Nicholas Krause wrote: > 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 Applied with this fixup on top: >>From 3108f03ce20adf6429cb130b44da528ae85fc68d Mon Sep 17 00:00:00 2001 From: Joerg Roedel 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. Signed-off-by: Joerg Roedel --- drivers/iommu/dmar.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index add177a..62a400c 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: -- 1.8.4.5