lkml.org 
[lkml]   [2012]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] 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>
---

drivers/vfio/pci/vfio_pci.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

--- linux.orig/drivers/vfio/pci/vfio_pci.c 2012-10-23 18:21:57.118168335 +0800
+++ linux/drivers/vfio/pci/vfio_pci.c 2012-11-02 10:39:36.101317628 +0800
@@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_
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);

\
 
 \ /
  Last update: 2012-11-02 04:21    [W:0.030 / U:1.996 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site