mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: Nicholas Krause <xerofoify@gmail.com>
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu
Date: Mon, 4 Jan 2016 17:16:16 +0100	[thread overview]
Message-ID: <20160104161616.GP18805@8bytes.org> (raw)
In-Reply-To: <1451365811-19111-1-git-send-email-xerofoify@gmail.com>

On Tue, Dec 29, 2015 at 12:10:11AM -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 <xerofoify@gmail.com>
> ---
>  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;
> +	}

This leaves a dangling pointer to the iommu in drhd->iommu.

>  
>  	return 0;
> -

That blank line improves readability of the code, please leave it in.

>  err_unmap:
>  	unmap_iommu(iommu);
>  error_free_seq_id:


  parent reply	other threads:[~2016-01-04 16:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1451365811-19111-1-git-send-email-xerofoify@gmail.com>
2015-12-29  7:15 ` Wan ZongShun
2016-01-04 16:16 ` Joerg Roedel [this message]
     [not found]   ` <6B8E4732-8366-4981-8A38-BA542A09F1E0@gmail.com>
2016-01-04 16:38     ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160104161616.GP18805@8bytes.org \
    --to=joro@8bytes.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xerofoify@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome