Skip to content

Commit

Permalink
vfio: simplify kmalloc+copy_from_user to memdup_user
Browse files Browse the repository at this point in the history
Generated by: coccinelle/api/memdup_user.cocci

Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Fengguang Wu authored and Alex Williamson committed Dec 7, 2012
1 parent 1afa471 commit 3a1f704
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions drivers/vfio/pci/vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3a1f704

Please sign in to comment.