提交 3a1f7041 编写于 作者: F Fengguang Wu 提交者: Alex Williamson

vfio: simplify kmalloc+copy_from_user to memdup_user

Generated by: coccinelle/api/memdup_user.cocci
Acked-by: NJulia Lawall <julia.lawall@lip6.fr>
Reported-by: NFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
上级 1afa4717
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册