linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu
       [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
  1 sibling, 0 replies; 3+ messages in thread
From: Wan ZongShun @ 2015-12-29  7:15 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: Joerg Roedel, iommu, linux-kernel

2015-12-29 13:10 GMT+08:00 Nicholas Krause <xerofoify@gmail.com>:
> 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;
> +       }

If so, will this bad 'iommu->iommu_dev' break your iommu work?  It
seems not necessary.

>
>         return 0;
> -
>  err_unmap:
>         unmap_iommu(iommu);
>  error_free_seq_id:
> --
> 2.5.0
>
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu



-- 
---
Vincent Wan(Zongshun)
www.mcuos.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu
       [not found] <1451365811-19111-1-git-send-email-xerofoify@gmail.com>
  2015-12-29  7:15 ` [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu Wan ZongShun
@ 2016-01-04 16:16 ` Joerg Roedel
       [not found]   ` <6B8E4732-8366-4981-8A38-BA542A09F1E0@gmail.com>
  1 sibling, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2016-01-04 16:16 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: iommu, linux-kernel

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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu
       [not found]   ` <6B8E4732-8366-4981-8A38-BA542A09F1E0@gmail.com>
@ 2016-01-04 16:38     ` Joerg Roedel
  0 siblings, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2016-01-04 16:38 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: iommu, linux-kernel

On Mon, Jan 04, 2016 at 11:27:10AM -0500, Nicholas Krause wrote:
> Yes that's true and was wondering if you want me to fix it up to set
> the pointer back to null first or if preferred around safe state. 

The best solution is to set the dmar->iommu pointer after the error
check for iommu_device_create().



	Joerg


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-04 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1451365811-19111-1-git-send-email-xerofoify@gmail.com>
2015-12-29  7:15 ` [PATCH] iommu:Check that iommu_device_create has completed successfully in alloc_iommu Wan ZongShun
2016-01-04 16:16 ` Joerg Roedel
     [not found]   ` <6B8E4732-8366-4981-8A38-BA542A09F1E0@gmail.com>
2016-01-04 16:38     ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).