MIPS: kvm: Fix ioctl error handling.
authorMichael S. Tsirkin <mst@redhat.com>
Sun, 28 Feb 2016 15:35:59 +0000 (17:35 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 9 Mar 2016 18:15:18 +0000 (13:15 -0500)
commitd850c054f3aeedf5e18290d14b097b5ed67fa9fb
treef19db265deb657b5277a64b65f02c51597c8be19
parent222b341c1063cb7aa497d7ed051ccb60349f54bb
MIPS: kvm: Fix ioctl error handling.

[ Upstream commit 887349f69f37e71e2a8bfbd743831625a0b2ff51 ]

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

Fix up kvm on mips to do
return copy_to_user(...)) ?  -EFAULT : 0;
and
return copy_from_user(...)) ?  -EFAULT : 0;

everywhere.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org
Cc: kvm@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/12709/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/mips/kvm/mips.c