summaryrefslogtreecommitdiff
path: root/drivers/vhost/vdpa.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-05-23 11:33:26 +0300
committerMichael S. Tsirkin <mst@redhat.com>2022-05-31 19:45:10 +0300
commitf4a8686ec7a34f940d36784872036fbacb1b4623 (patch)
treeebe14565c752fb92a0a906cee6058b5a57b4850b /drivers/vhost/vdpa.c
parent1f97b9785076d32fbabb8fa23889f9969c84118d (diff)
downloadlinux-f4a8686ec7a34f940d36784872036fbacb1b4623.tar.xz
vhost-vdpa: return -EFAULT on copy_to_user() failure
The copy_to_user() function returns the number of bytes remaining to be copied. However, we need to return a negative error code, -EFAULT, to the user. Fixes: 87f4c217413a ("vhost-vdpa: introduce uAPI to get the number of virtqueue groups") Fixes: e96ef636f154 ("vhost-vdpa: introduce uAPI to get the number of address spaces") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Message-Id: <YotG1vXKXXSayr63@kili> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Diffstat (limited to 'drivers/vhost/vdpa.c')
-rw-r--r--drivers/vhost/vdpa.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 3e86080041fc..935a1d0ddb97 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -609,11 +609,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
r = vhost_vdpa_get_vring_num(v, argp);
break;
case VHOST_VDPA_GET_GROUP_NUM:
- r = copy_to_user(argp, &v->vdpa->ngroups,
- sizeof(v->vdpa->ngroups));
+ if (copy_to_user(argp, &v->vdpa->ngroups,
+ sizeof(v->vdpa->ngroups)))
+ r = -EFAULT;
break;
case VHOST_VDPA_GET_AS_NUM:
- r = copy_to_user(argp, &v->vdpa->nas, sizeof(v->vdpa->nas));
+ if (copy_to_user(argp, &v->vdpa->nas, sizeof(v->vdpa->nas)))
+ r = -EFAULT;
break;
case VHOST_SET_LOG_BASE:
case VHOST_SET_LOG_FD: