Commit c4aec310 authored by Dan Carpenter's avatar Dan Carpenter Committed by Alex Williamson

vfio/pci: return -EFAULT if copy_to_user fails

The copy_to_user() function returns the number of bytes that were not
copied but we want to return -EFAULT on error here.

Fixes: 188ad9d6 ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent a13b6459
...@@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data, ...@@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
info.cap_offset = 0; info.cap_offset = 0;
} else { } else {
vfio_info_cap_shift(&caps, sizeof(info)); vfio_info_cap_shift(&caps, sizeof(info));
ret = copy_to_user((void __user *)arg + if (copy_to_user((void __user *)arg +
sizeof(info), caps.buf, sizeof(info), caps.buf,
caps.size); caps.size)) {
if (ret) {
kfree(caps.buf); kfree(caps.buf);
return ret; return -EFAULT;
} }
info.cap_offset = sizeof(info); info.cap_offset = sizeof(info);
} }
......
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