Skip to content

Commit

Permalink
vfio/pci: 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 that were not
copied but we want to return -EFAULT on error here.

Fixes: 188ad9d ('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>
  • Loading branch information
Dan Carpenter authored and Alex Williamson committed Feb 26, 2016

Unverified

No user is associated with the committer email.
1 parent a13b645 commit c4aec31
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/vfio/pci/vfio_pci.c
Original file line number Diff line number Diff line change
@@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
info.cap_offset = 0;
} else {
vfio_info_cap_shift(&caps, sizeof(info));
ret = copy_to_user((void __user *)arg +
sizeof(info), caps.buf,
caps.size);
if (ret) {
if (copy_to_user((void __user *)arg +
sizeof(info), caps.buf,
caps.size)) {
kfree(caps.buf);
return ret;
return -EFAULT;
}
info.cap_offset = sizeof(info);
}

0 comments on commit c4aec31

Please sign in to comment.