summaryrefslogtreecommitdiffstats
path: root/drivers/vfio/pci
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2022-12-08 17:01:26 +0100
committerAlex Williamson <alex.williamson@redhat.com>2022-12-12 22:10:12 +0100
commitfe3dd71db2b81c202bc80532bbe0e07238a45ed9 (patch)
treec31e1f1ba6c8fe5181adb6532162dbc026b2f7c3 /drivers/vfio/pci
parentsamples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe() (diff)
downloadlinux-fe3dd71db2b81c202bc80532bbe0e07238a45ed9.tar.xz
linux-fe3dd71db2b81c202bc80532bbe0e07238a45ed9.zip
vfio/mlx5: fix error code in mlx5vf_precopy_ioctl()
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: 0dce165b1adf ("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>
Diffstat (limited to 'drivers/vfio/pci')
-rw-r--r--drivers/vfio/pci/mlx5/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
index cd90eb86128c..94f7a0fd10e8 100644
--- a/drivers/vfio/pci/mlx5/main.c
+++ b/drivers/vfio/pci/mlx5/main.c
@@ -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: