aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2016-02-25 02:52:12 -0500
committerAlex Williamson <alex.williamson@redhat.com>2016-02-25 23:48:42 -0500
commitc4aec3101319f84363a57e09086c2aff6c60a3c3 (patch)
tree553031dcd815fc2059ecb467d611c23df4d565ef
parenta13b64591747e8a4ab2df24540a17fca34de2d34 (diff)
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: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--drivers/vfio/pci/vfio_pci.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 1ce1d364308c..98059df9cff6 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
664 info.cap_offset = 0; 664 info.cap_offset = 0;
665 } else { 665 } else {
666 vfio_info_cap_shift(&caps, sizeof(info)); 666 vfio_info_cap_shift(&caps, sizeof(info));
667 ret = copy_to_user((void __user *)arg + 667 if (copy_to_user((void __user *)arg +
668 sizeof(info), caps.buf, 668 sizeof(info), caps.buf,
669 caps.size); 669 caps.size)) {
670 if (ret) {
671 kfree(caps.buf); 670 kfree(caps.buf);
672 return ret; 671 return -EFAULT;
673 } 672 }
674 info.cap_offset = sizeof(info); 673 info.cap_offset = sizeof(info);
675 } 674 }