Commit 3a1f7041 authored by Fengguang Wu's avatar Fengguang Wu Committed by Alex Williamson

vfio: simplify kmalloc+copy_from_user to memdup_user

Generated by: coccinelle/api/memdup_user.cocci
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 1afa4717
...@@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_data, ...@@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_data,
hdr.count > vfio_pci_get_irq_count(vdev, hdr.index)) hdr.count > vfio_pci_get_irq_count(vdev, hdr.index))
return -EINVAL; return -EINVAL;
data = kmalloc(hdr.count * size, GFP_KERNEL); data = memdup_user((void __user *)(arg + minsz),
if (!data) hdr.count * size);
return -ENOMEM; if (IS_ERR(data))
return PTR_ERR(data);
if (copy_from_user(data, (void __user *)(arg + minsz),
hdr.count * size)) {
kfree(data);
return -EFAULT;
}
} }
mutex_lock(&vdev->igate); mutex_lock(&vdev->igate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment