aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vfio/pci
diff options
context:
space:
mode:
authorFengguang Wu <fengguang.wu@intel.com>2012-12-07 15:43:49 -0500
committerAlex Williamson <alex.williamson@redhat.com>2012-12-07 15:43:49 -0500
commit3a1f7041ddd59ec3aceb042892f811cc76e05288 (patch)
tree6e5e3548698eb68a5fdd15864e0190c1dedac164 /drivers/vfio/pci
parent1afa471706963643ceeda7cbbe9c605a1e883d53 (diff)
vfio: simplify kmalloc+copy_from_user to memdup_user
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>
Diffstat (limited to 'drivers/vfio/pci')
-rw-r--r--drivers/vfio/pci/vfio_pci.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 6c119944bbb6..a4dc21b9cb06 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_data,
327 hdr.count > vfio_pci_get_irq_count(vdev, hdr.index)) 327 hdr.count > vfio_pci_get_irq_count(vdev, hdr.index))
328 return -EINVAL; 328 return -EINVAL;
329 329
330 data = kmalloc(hdr.count * size, GFP_KERNEL); 330 data = memdup_user((void __user *)(arg + minsz),
331 if (!data) 331 hdr.count * size);
332 return -ENOMEM; 332 if (IS_ERR(data))
333 333 return PTR_ERR(data);
334 if (copy_from_user(data, (void __user *)(arg + minsz),
335 hdr.count * size)) {
336 kfree(data);
337 return -EFAULT;
338 }
339 } 334 }
340 335
341 mutex_lock(&vdev->igate); 336 mutex_lock(&vdev->igate);