Commit f4a8686e authored by Dan Carpenter's avatar Dan Carpenter Committed by Michael S. Tsirkin

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Message-Id: <YotG1vXKXXSayr63@kili>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
parent 1f97b978
...@@ -609,11 +609,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, ...@@ -609,11 +609,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
r = vhost_vdpa_get_vring_num(v, argp); r = vhost_vdpa_get_vring_num(v, argp);
break; break;
case VHOST_VDPA_GET_GROUP_NUM: case VHOST_VDPA_GET_GROUP_NUM:
r = copy_to_user(argp, &v->vdpa->ngroups, if (copy_to_user(argp, &v->vdpa->ngroups,
sizeof(v->vdpa->ngroups)); sizeof(v->vdpa->ngroups)))
r = -EFAULT;
break; break;
case VHOST_VDPA_GET_AS_NUM: 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; break;
case VHOST_SET_LOG_BASE: case VHOST_SET_LOG_BASE:
case VHOST_SET_LOG_FD: case VHOST_SET_LOG_FD:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment