Skip to content

Commit fe3dd71

Browse files
error27awilliam
authored andcommitted
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: 0dce165 ("vfio/mlx5: Introduce vfio precopy ioctl implementation") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Yishai Hadas <[email protected]> Link: https://lore.kernel.org/r/Y5IKVknlf5Z5NPtU@kili Signed-off-by: Alex Williamson <[email protected]>
1 parent d1f0f50 commit fe3dd71

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/vfio/pci/mlx5/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,10 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,
404404

405405
done:
406406
mlx5vf_state_mutex_unlock(mvdev);
407-
return copy_to_user((void __user *)arg, &info, minsz);
407+
if (copy_to_user((void __user *)arg, &info, minsz))
408+
return -EFAULT;
409+
return 0;
410+
408411
err_migf_unlock:
409412
mutex_unlock(&migf->lock);
410413
err_state_unlock:

0 commit comments

Comments
 (0)