Skip to content

Commit

Permalink
vfio: Fix handling of error returned by 'vfio_group_get_from_dev()'
Browse files Browse the repository at this point in the history
'vfio_group_get_from_dev()' seems to return only NULL on error, not an
error pointer.

Fixes: 2169037 ("vfio iommu: Added pin and unpin callback functions to vfio_iommu_driver_ops")
Fixes: c086de8 ("vfio iommu: Add blocking notifier to notify DMA_UNMAP")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Christophe JAILLET authored and Alex Williamson committed Dec 1, 2016
1 parent 5ba6de9 commit d256459
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 -ENODEV;

ret = vfio_group_add_container_user(group);
if (ret)
Expand Down Expand Up @@ -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 -ENODEV;

ret = vfio_group_add_container_user(group);
if (ret)
Expand Down Expand Up @@ -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 -ENODEV;

ret = vfio_group_add_container_user(group);
if (ret)
Expand Down Expand Up @@ -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 -ENODEV;

ret = vfio_group_add_container_user(group);
if (ret)
Expand Down

0 comments on commit d256459

Please sign in to comment.