From patchwork Sat May 15 21:18:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 3398 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Sat, 15 May 2010 21:19:22 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Sat, 15 May 2010 22:46:20 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1ODOlW-0005Fh-A8; Sat, 15 May 2010 21:19:22 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755678Ab0EOVSq (ORCPT + 1 other); Sat, 15 May 2010 17:18:46 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:41729 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755487Ab0EOVSp (ORCPT ); Sat, 15 May 2010 17:18:45 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id 89B8719BB6E; Sat, 15 May 2010 23:18:44 +0200 (CEST) Received: from mgw2.diku.dk ([127.0.0.1]) by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08226-12; Sat, 15 May 2010 23:18:40 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw2.diku.dk (Postfix) with ESMTP id 741B419BB6D; Sat, 15 May 2010 23:18:40 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id ECEF26DFD1E; Sat, 15 May 2010 23:11:28 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id 549E2200BE; Sat, 15 May 2010 23:18:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id 4DCF8200BC; Sat, 15 May 2010 23:18:40 +0200 (CEST) Date: Sat, 15 May 2010 23:18:40 +0200 (CEST) From: Julia Lawall To: Huang Shijie , Kang Yong , Zhang Xiaobing , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 18/37] drivers/media/video/tlg2300: Use kmemdup Message-ID: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Julia Lawall 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 --- drivers/media/video/tlg2300/pd-main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -u -p a/drivers/media/video/tlg2300/pd-main.c b/drivers/media/video/tlg2300/pd-main.c --- 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_ 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);