vfio: fix ioctl error handling
authorMichael S. Tsirkin <mst@redhat.com>
Sun, 28 Feb 2016 14:31:39 +0000 (16:31 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 9 Mar 2016 18:15:13 +0000 (13:15 -0500)
commit1590808b43559d8330599158453f28f1b16ffd54
tree796afaafd1f8659f23be2104f8a07fd26da3754f
parent9b77cd137fd841d7a14e1c9428cfc49f4df0306e
vfio: fix ioctl error handling

[ Upstream commit 8160c4e455820d5008a1116d2dca35f0363bb062 ]

Calling return copy_to_user(...) in an ioctl will not
do the right thing if there's a pagefault:
copy_to_user returns the number of bytes not copied
in this case.

Fix up vfio to do
return copy_to_user(...)) ?
-EFAULT : 0;

everywhere.

Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/vfio/pci/vfio_pci.c
drivers/vfio/platform/vfio_platform_common.c
drivers/vfio/vfio_iommu_type1.c