Skip to content

Commit

Permalink
vfio/mlx5: fix error code in mlx5vf_precopy_ioctl()
Browse files Browse the repository at this point in the history
The copy_to_user() function returns the number of bytes remaining to
be copied but we want to return a negative error code here.

Fixes: 0dce165 ("vfio/mlx5: Introduce vfio precopy ioctl implementation")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/Y5IKVknlf5Z5NPtU@kili
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Dan Carpenter authored and Alex Williamson committed Dec 12, 2022
1 parent d1f0f50 commit fe3dd71
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/vfio/pci/mlx5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,

done:
mlx5vf_state_mutex_unlock(mvdev);
return copy_to_user((void __user *)arg, &info, minsz);
if (copy_to_user((void __user *)arg, &info, minsz))
return -EFAULT;
return 0;

err_migf_unlock:
mutex_unlock(&migf->lock);
err_state_unlock:
Expand Down

0 comments on commit fe3dd71

Please sign in to comment.