From 2b3c543a839cafeb3edd7e1a2202d86318801fd9 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 1 Jul 2010 01:41:44 -0300 Subject: [PATCH] V4L/DVB: drivers/media/video/tlg2300: Use kmemdup Use kmemdup when some other buffer is immediately copied into the allocated region. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); // Signed-off-by: Julia Lawall Signed-off-by: Douglas Schilling Landgraf Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/tlg2300/pd-main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/video/tlg2300/pd-main.c b/drivers/media/video/tlg2300/pd-main.c index 256cc558ba1..4555f4a5f4c 100644 --- a/drivers/media/video/tlg2300/pd-main.c +++ b/drivers/media/video/tlg2300/pd-main.c @@ -227,12 +227,11 @@ static int firmware_download(struct usb_device *udev) fwlength = fw->size; - fwbuf = kzalloc(fwlength, GFP_KERNEL); + fwbuf = kmemdup(fw->data, fwlength, GFP_KERNEL); if (!fwbuf) { ret = -ENOMEM; goto out; } - memcpy(fwbuf, fw->data, fwlength); max_packet_size = udev->ep_out[0x1]->desc.wMaxPacketSize; log("\t\t download size : %d", (int)max_packet_size); -- 2.11.4.GIT