Commit 662d4cea authored by Benoit Taine's avatar Benoit Taine Committed by Jiri Kosina

HID: uhid: Use kmemdup instead of kmalloc + memcpy

This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: default avatarBenoit Taine <benoit.taine@lip6.fr>
Reviewed-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 37c492c8
...@@ -441,12 +441,11 @@ static int uhid_dev_create2(struct uhid_device *uhid, ...@@ -441,12 +441,11 @@ static int uhid_dev_create2(struct uhid_device *uhid,
if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE) if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE)
return -EINVAL; return -EINVAL;
uhid->rd_data = kmalloc(uhid->rd_size, GFP_KERNEL); uhid->rd_data = kmemdup(ev->u.create2.rd_data, uhid->rd_size,
GFP_KERNEL);
if (!uhid->rd_data) if (!uhid->rd_data)
return -ENOMEM; return -ENOMEM;
memcpy(uhid->rd_data, ev->u.create2.rd_data, uhid->rd_size);
hid = hid_allocate_device(); hid = hid_allocate_device();
if (IS_ERR(hid)) { if (IS_ERR(hid)) {
ret = PTR_ERR(hid); ret = PTR_ERR(hid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment