diff options
author | Muhammad Falak R Wani <falakreyaz@gmail.com> | 2016-05-20 17:48:56 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-31 13:18:10 +0200 |
commit | 655745b0d1ebeceb0453f1c6adca154a4fac0ad5 (patch) | |
tree | 038d825baf87f9f7a7845c52e3203aa2d0ef41fc /drivers/misc/vmw_vmci | |
parent | b58189b3c5cf54689a0c154e4d9cff918a29ab0b (diff) | |
download | linux-655745b0d1ebeceb0453f1c6adca154a4fac0ad5.tar.gz linux-655745b0d1ebeceb0453f1c6adca154a4fac0ad5.tar.bz2 linux-655745b0d1ebeceb0453f1c6adca154a4fac0ad5.zip |
VMCI: use memdup_user().
Use memdup_user to duplicate a memory region from user-space to
kernel-space, instead of open coding using kmalloc & copy_from_user.
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/vmw_vmci')
-rw-r--r-- | drivers/misc/vmw_vmci/vmci_host.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers/misc/vmw_vmci/vmci_host.c index 9ec262a52656..ec090105eb4b 100644 --- a/drivers/misc/vmw_vmci/vmci_host.c +++ b/drivers/misc/vmw_vmci/vmci_host.c @@ -381,18 +381,12 @@ static int vmci_host_do_send_datagram(struct vmci_host_dev *vmci_host_dev, return -EINVAL; } - dg = kmalloc(send_info.len, GFP_KERNEL); - if (!dg) { + dg = memdup_user((void __user *)(uintptr_t)send_info.addr, + send_info.len); + if (IS_ERR(dg)) { vmci_ioctl_err( "cannot allocate memory to dispatch datagram\n"); - return -ENOMEM; - } - - if (copy_from_user(dg, (void __user *)(uintptr_t)send_info.addr, - send_info.len)) { - vmci_ioctl_err("error getting datagram\n"); - kfree(dg); - return -EFAULT; + return PTR_ERR(dg); } if (VMCI_DG_SIZE(dg) != send_info.len) { |