Skip to content

Commit

Permalink
vhost_vdpa: return -EFAULT if copy_to_user() fails
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 this should return -EFAULT to the user.

Fixes: 1b48dc0 ("vhost: vdpa: report iova range")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X8c32z5EtDsMyyIL@mwanda
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
  • Loading branch information
Dan Carpenter authored and Michael S. Tsirkin committed Dec 2, 2020
1 parent 98701a2 commit 2c60274
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/vhost/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
.last = v->range.last,
};

return copy_to_user(argp, &range, sizeof(range));
if (copy_to_user(argp, &range, sizeof(range)))
return -EFAULT;
return 0;
}

static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
Expand Down

0 comments on commit 2c60274

Please sign in to comment.