kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] vfio: vfio_group_get_from_dev() doesn't return error pointers
@ 2016-11-24 11:08 Dan Carpenter
  2016-11-28 12:17 ` Kirti Wankhede
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-11-24 11:08 UTC (permalink / raw)
  To: Alex Williamson, Kirti Wankhede; +Cc: kvm, kernel-janitors

These are all checking for IS_ERR() but vfio_group_get_from_dev()
returns NULL pointers on error.

Fixes: c086de818dd8 ("vfio iommu: Add blocking notifier to notify DMA_UNMAP")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 0aac3ca..952e68c 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1933,8 +1933,8 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage,
 		return -E2BIG;
 
 	group = vfio_group_get_from_dev(dev);
-	if (IS_ERR(group))
-		return PTR_ERR(group);
+	if (!group)
+		return -EINVAL;
 
 	ret = vfio_group_add_container_user(group);
 	if (ret)
@@ -1982,8 +1982,8 @@ int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn, int npage)
 		return -E2BIG;
 
 	group = vfio_group_get_from_dev(dev);
-	if (IS_ERR(group))
-		return PTR_ERR(group);
+	if (!group)
+		return -EINVAL;
 
 	ret = vfio_group_add_container_user(group);
 	if (ret)
@@ -2019,8 +2019,8 @@ int vfio_register_notifier(struct device *dev, struct notifier_block *nb)
 		return -EINVAL;
 
 	group = vfio_group_get_from_dev(dev);
-	if (IS_ERR(group))
-		return PTR_ERR(group);
+	if (!group)
+		return -EINVAL;
 
 	ret = vfio_group_add_container_user(group);
 	if (ret)
@@ -2055,8 +2055,8 @@ int vfio_unregister_notifier(struct device *dev, struct notifier_block *nb)
 		return -EINVAL;
 
 	group = vfio_group_get_from_dev(dev);
-	if (IS_ERR(group))
-		return PTR_ERR(group);
+	if (!group)
+		return -EINVAL;
 
 	ret = vfio_group_add_container_user(group);
 	if (ret)

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

* Re: [patch] vfio: vfio_group_get_from_dev() doesn't return error pointers
  2016-11-24 11:08 [patch] vfio: vfio_group_get_from_dev() doesn't return error pointers Dan Carpenter
@ 2016-11-28 12:17 ` Kirti Wankhede
  0 siblings, 0 replies; 2+ messages in thread
From: Kirti Wankhede @ 2016-11-28 12:17 UTC (permalink / raw)
  To: Dan Carpenter, Alex Williamson; +Cc: kvm, kernel-janitors



On 11/24/2016 4:38 PM, Dan Carpenter wrote:
> These are all checking for IS_ERR() but vfio_group_get_from_dev()
> returns NULL pointers on error.
> 
> Fixes: c086de818dd8 ("vfio iommu: Add blocking notifier to notify DMA_UNMAP")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 0aac3ca..952e68c 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -1933,8 +1933,8 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage,
>  		return -E2BIG;
>  
>  	group = vfio_group_get_from_dev(dev);
> -	if (IS_ERR(group))
> -		return PTR_ERR(group);
> +	if (!group)
> +		return -EINVAL;
>  
>  	ret = vfio_group_add_container_user(group);
>  	if (ret)
> @@ -1982,8 +1982,8 @@ int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn, int npage)
>  		return -E2BIG;
>  
>  	group = vfio_group_get_from_dev(dev);
> -	if (IS_ERR(group))
> -		return PTR_ERR(group);
> +	if (!group)
> +		return -EINVAL;
>  
>  	ret = vfio_group_add_container_user(group);
>  	if (ret)
> @@ -2019,8 +2019,8 @@ int vfio_register_notifier(struct device *dev, struct notifier_block *nb)
>  		return -EINVAL;
>  
>  	group = vfio_group_get_from_dev(dev);
> -	if (IS_ERR(group))
> -		return PTR_ERR(group);
> +	if (!group)
> +		return -EINVAL;
>  
>  	ret = vfio_group_add_container_user(group);
>  	if (ret)
> @@ -2055,8 +2055,8 @@ int vfio_unregister_notifier(struct device *dev, struct notifier_block *nb)
>  		return -EINVAL;
>  
>  	group = vfio_group_get_from_dev(dev);
> -	if (IS_ERR(group))
> -		return PTR_ERR(group);
> +	if (!group)
> +		return -EINVAL;
>  
>  	ret = vfio_group_add_container_user(group);
>  	if (ret)
> --

This makes sense. Thanks for fixing this.
Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>


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

end of thread, other threads:[~2016-11-28 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-24 11:08 [patch] vfio: vfio_group_get_from_dev() doesn't return error pointers Dan Carpenter
2016-11-28 12:17 ` Kirti Wankhede

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).