From: Shyam Saini Date: Fri, 23 Dec 2016 19:34:36 +0000 (-0200) Subject: [media] media: usb: cpia2: Use kmemdup instead of kmalloc and memcpy X-Git-Tag: v4.11-rc1~132^2~145 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9945cf9997b5fc10b47c010cdb40b2753ccc77d9;p=karo-tx-linux.git [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: Shyam Saini Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c index 7a50662348f6..1c7e16e5d88b 100644 --- a/drivers/media/usb/cpia2/cpia2_usb.c +++ b/drivers/media/usb/cpia2/cpia2_usb.c @@ -547,12 +547,10 @@ static int write_packet(struct usb_device *udev, if (!registers || size <= 0) return -EINVAL; - buf = kmalloc(size, GFP_KERNEL); + buf = kmemdup(registers, size, GFP_KERNEL); if (!buf) return -ENOMEM; - memcpy(buf, registers, size); - ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), request,