All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
To: Nicholas Krause <xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  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:

WARNING: multiple messages have this Message-ID (diff)
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: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29  5:10 [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu Nicholas Krause
     [not found] ` <1451365811-19111-1-git-send-email-xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-29  7:15   ` Wan ZongShun
2015-12-29  7:15     ` Wan ZongShun
     [not found]     ` <CAKT61h-n6=enWPAmEkPE36VZvrGFn9_Zj0y4+DdkOB33jyELUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-29 16:43       ` nick
2016-01-04 16:16   ` Joerg Roedel [this message]
2016-01-04 16:16     ` Joerg Roedel
     [not found]     ` <20160104161616.GP18805-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2016-01-04 16:27       ` Nicholas Krause
     [not found]         ` <6B8E4732-8366-4981-8A38-BA542A09F1E0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-04 16:38           ` Joerg Roedel
2016-01-04 16:38             ` Joerg Roedel
  -- strict thread matches above, loose matches on Subject: below --
2016-01-04 23:27 Nicholas Krause

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-zlv9swrftaidnm+yrofe0a@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=xerofoify-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.