From patchwork Sat Aug 1 08:53:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 1434 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Sat, 01 Aug 2009 08:56:58 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra.chehab.org with IMAP (fetchmail-6.3.6) for (single-drop); Sat, 01 Aug 2009 10:54:21 -0300 (BRT) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MXAOg-0008Dy-BN; Sat, 01 Aug 2009 08:56:58 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752459AbZHAI4h (ORCPT + 1 other); Sat, 1 Aug 2009 04:56:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752183AbZHAI4e (ORCPT ); Sat, 1 Aug 2009 04:56:34 -0400 Received: from mgw1.diku.dk ([130.225.96.91]:50559 "EHLO mgw1.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbZHAI4c (ORCPT ); Sat, 1 Aug 2009 04:56:32 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 4AAF052C365; Sat, 1 Aug 2009 10:56:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4-fF84SqnyWL; Sat, 1 Aug 2009 10:56:29 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id 5D55A52C2F2; Sat, 1 Aug 2009 10:53:38 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id 549D66DFAE8; Sat, 1 Aug 2009 10:52:48 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id 4603E154DE3; Sat, 1 Aug 2009 10:53:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id 448361549A9; Sat, 1 Aug 2009 10:53:38 +0200 (CEST) Date: Sat, 1 Aug 2009 10:53:38 +0200 (CEST) From: Julia Lawall To: frank@zago.net, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 3/10] drivers/media/video/gspca: introduce missing kfree 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 Error handling code following a kmalloc should free the allocated data. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...x...+> } ( x->f1 = E | (x->f1 == NULL || ...) | f(...,x->f1,...) ) ...> ( return \(0\|<+...x...+>\|ptr\); | return@p2 ...; ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // Signed-off-by: Julia Lawall Acked-by: Erik Andrén --- drivers/media/video/gspca/m5602/m5602_s5k83a.c | 4 +++- 1 files changed, 3 insertions(+), 1 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 --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c index 7127321..6b89f33 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c @@ -178,8 +178,10 @@ sensor_found: sens_priv->settings = kmalloc(sizeof(s32)*ARRAY_SIZE(s5k83a_ctrls), GFP_KERNEL); - if (!sens_priv->settings) + if (!sens_priv->settings) { + kfree(sens_priv); return -ENOMEM; + } sd->gspca_dev.cam.cam_mode = s5k83a_modes; sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes);