Commit 9945cf99 authored by Shyam Saini's avatar Shyam Saini Committed by Mauro Carvalho Chehab

[media] media: usb: cpia2: Use kmemdup instead of kmalloc and memcpy

When some other buffer is immediately copied into allocated region.
Replace calls to kmalloc followed by a memcpy with a direct
call to kmemdup.
Signed-off-by: default avatarShyam Saini <mayhs11saini@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 01faa0d9
...@@ -547,12 +547,10 @@ static int write_packet(struct usb_device *udev, ...@@ -547,12 +547,10 @@ static int write_packet(struct usb_device *udev,
if (!registers || size <= 0) if (!registers || size <= 0)
return -EINVAL; return -EINVAL;
buf = kmalloc(size, GFP_KERNEL); buf = kmemdup(registers, size, GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
memcpy(buf, registers, size);
ret = usb_control_msg(udev, ret = usb_control_msg(udev,
usb_sndctrlpipe(udev, 0), usb_sndctrlpipe(udev, 0),
request, request,
......
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