All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio: check iommu_group_set_name() return value
@ 2022-06-25 11:42 Liam Ni
  2022-06-29  6:21 ` Tian, Kevin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Liam Ni @ 2022-06-25 11:42 UTC (permalink / raw)
  To: alex.williamson, cohuck; +Cc: kvm, linux-kernel, zhiguangni01

As iommu_group_set_name() can fail,we should check the return value.

Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
---
 drivers/vfio/vfio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 61e71c1154be..ca823eeac237 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -504,7 +504,9 @@ static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
 	if (IS_ERR(iommu_group))
 		return ERR_CAST(iommu_group);
 
-	iommu_group_set_name(iommu_group, "vfio-noiommu");
+	ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
+	if (ret)
+		goto out_put_group;
 	ret = iommu_group_add_device(iommu_group, dev);
 	if (ret)
 		goto out_put_group;
-- 
2.25.1


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

* RE: [PATCH] vfio: check iommu_group_set_name() return value
  2022-06-25 11:42 [PATCH] vfio: check iommu_group_set_name() return value Liam Ni
@ 2022-06-29  6:21 ` Tian, Kevin
  2022-06-29 17:54 ` Jason Gunthorpe
  2022-06-30 19:51 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2022-06-29  6:21 UTC (permalink / raw)
  To: Liam Ni, alex.williamson, cohuck; +Cc: kvm, linux-kernel

> From: Liam Ni <zhiguangni01@gmail.com>
> Sent: Saturday, June 25, 2022 7:43 PM
> 
> As iommu_group_set_name() can fail,we should check the return value.
> 
> Signed-off-by: Liam Ni <zhiguangni01@gmail.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>.

btw you probably also want to change other callers of this
function for the same issue.

> ---
>  drivers/vfio/vfio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 61e71c1154be..ca823eeac237 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -504,7 +504,9 @@ static struct vfio_group
> *vfio_noiommu_group_alloc(struct device *dev,
>  	if (IS_ERR(iommu_group))
>  		return ERR_CAST(iommu_group);
> 
> -	iommu_group_set_name(iommu_group, "vfio-noiommu");
> +	ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
> +	if (ret)
> +		goto out_put_group;
>  	ret = iommu_group_add_device(iommu_group, dev);
>  	if (ret)
>  		goto out_put_group;
> --
> 2.25.1


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

* Re: [PATCH] vfio: check iommu_group_set_name() return value
  2022-06-25 11:42 [PATCH] vfio: check iommu_group_set_name() return value Liam Ni
  2022-06-29  6:21 ` Tian, Kevin
@ 2022-06-29 17:54 ` Jason Gunthorpe
  2022-06-30 19:51 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2022-06-29 17:54 UTC (permalink / raw)
  To: Liam Ni; +Cc: alex.williamson, cohuck, kvm, linux-kernel

On Sat, Jun 25, 2022 at 07:42:39PM +0800, Liam Ni wrote:
> As iommu_group_set_name() can fail,we should check the return value.
> 
> Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
> ---
>  drivers/vfio/vfio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

I prefer this - but notice it is not a bug because if
iommu_group_set_name() fails then iommu_group_add_device() will return
-ENOMEM.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason

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

* Re: [PATCH] vfio: check iommu_group_set_name() return value
  2022-06-25 11:42 [PATCH] vfio: check iommu_group_set_name() return value Liam Ni
  2022-06-29  6:21 ` Tian, Kevin
  2022-06-29 17:54 ` Jason Gunthorpe
@ 2022-06-30 19:51 ` Alex Williamson
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Williamson @ 2022-06-30 19:51 UTC (permalink / raw)
  To: Liam Ni; +Cc: cohuck, kvm, linux-kernel

On Sat, 25 Jun 2022 19:42:39 +0800
Liam Ni <zhiguangni01@gmail.com> wrote:

> As iommu_group_set_name() can fail,we should check the return value.
> 
> Signed-off-by: Liam Ni <zhiguangni01@gmail.com>
> ---
>  drivers/vfio/vfio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied to vfio next branch for v5.20.  Thanks,

Alex

> 
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 61e71c1154be..ca823eeac237 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -504,7 +504,9 @@ static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
>  	if (IS_ERR(iommu_group))
>  		return ERR_CAST(iommu_group);
>  
> -	iommu_group_set_name(iommu_group, "vfio-noiommu");
> +	ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
> +	if (ret)
> +		goto out_put_group;
>  	ret = iommu_group_add_device(iommu_group, dev);
>  	if (ret)
>  		goto out_put_group;


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

end of thread, other threads:[~2022-06-30 19:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-25 11:42 [PATCH] vfio: check iommu_group_set_name() return value Liam Ni
2022-06-29  6:21 ` Tian, Kevin
2022-06-29 17:54 ` Jason Gunthorpe
2022-06-30 19:51 ` Alex Williamson

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.