mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
vfio: simplify kmalloc+copy_from_user to memdup_user
Generated by: coccinelle/api/memdup_user.cocci Acked-by: Julia Lawall <[email protected]> Reported-by: Fengguang Wu <[email protected]> Signed-off-by: Alex Williamson <[email protected]>
This commit is contained in:
parent
1afa471706
commit
3a1f7041dd
1 changed files with 4 additions and 9 deletions
|
|
@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_data,
|
|||
hdr.count > vfio_pci_get_irq_count(vdev, hdr.index))
|
||||
return -EINVAL;
|
||||
|
||||
data = kmalloc(hdr.count * size, GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_from_user(data, (void __user *)(arg + minsz),
|
||||
hdr.count * size)) {
|
||||
kfree(data);
|
||||
return -EFAULT;
|
||||
}
|
||||
data = memdup_user((void __user *)(arg + minsz),
|
||||
hdr.count * size);
|
||||
if (IS_ERR(data))
|
||||
return PTR_ERR(data);
|
||||
}
|
||||
|
||||
mutex_lock(&vdev->igate);
|
||||
|
|
|
|||
Loading…
Reference in a new issue