From patchwork Wed Jan 20 23:58:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zummo X-Patchwork-Id: 43398 Return-Path: <3u5hXSw0MCfYYxskkm-emmejcrmucprcaf.grpra-jglsvemmejcepmsnq.amk@listserv.bounces.google.com> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-yx0-f158.google.com (mail-yx0-f158.google.com [209.85.210.158]) by ozlabs.org (Postfix) with ESMTP id 50591B7D15 for ; Thu, 21 Jan 2010 10:58:52 +1100 (EST) Received: by mail-yx0-f158.google.com with SMTP id 30sf4789149yxe.29 for ; Wed, 20 Jan 2010 15:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:date:from:to:cc:subject:message-id :in-reply-to:references:organization:x-mailer :x-this-is-a-real-message:mime-version:x-virus-scanned :x-virus-status:x-original-authentication-results:x-original-sender :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:x-thread-url:x-message-url:sender:list-unsubscribe :list-subscribe:content-type; bh=ih+qHjo8g5s8n8iULdU7yAI7OsdMlPSwMVFqiFl1W/0=; b=rRbJbcsPRqO4RK/dXQ85RtNfY1RzG+tL+7dwmbxEZLXAE4R3V3FxtK7pplWrjRh4hw vfuAxodyEIkzB98I5UoEOtDWYLK7zaJOJH/RqOmuSb2mnfLZN9BEOw8iJW7NXfjoopa7 TShWHmKxuXO/+iaAgfH6pB04X+wkRX4//XcIs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:date:from:to:cc:subject:message-id :in-reply-to:references:organization:x-mailer :x-this-is-a-real-message:mime-version:x-virus-scanned :x-virus-status:x-original-authentication-results:x-original-sender :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:x-thread-url:x-message-url:sender:list-unsubscribe :list-subscribe:content-type; b=ydkJc5vGGtUs2QYkyHhhQEOXL96FPbk4nWugQa4fwNA0gDhZEQ8AMegtGoXxy/z7sm Lh7JciKEmBX8cafG2idYt5hZSa7IPk+hIuFhzxPr7Y31SQUVKsP6CWqFLTprnydhPCjX qvtAfwarpWckrDGx1ghEUtCPz/27si7Uby4fk= Received: by 10.101.141.11 with SMTP id t11mr60141ann.12.1264031931746; Wed, 20 Jan 2010 15:58:51 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.204.26.139 with SMTP id e11ls26306bkc.1.p; Wed, 20 Jan 2010 15:58:51 -0800 (PST) Received: by 10.204.154.88 with SMTP id n24mr22278bkw.32.1264031930862; Wed, 20 Jan 2010 15:58:50 -0800 (PST) Received: by 10.204.154.88 with SMTP id n24mr22277bkw.32.1264031930841; Wed, 20 Jan 2010 15:58:50 -0800 (PST) Received: from elettra.colt-to.towertech.it (elettra.colt-to.towertech.it [213.215.222.70]) by gmr-mx.google.com with ESMTP id 17si33472bwz.4.2010.01.20.15.58.50; Wed, 20 Jan 2010 15:58:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of a.zummo@towertech.it designates 213.215.222.70 as permitted sender) client-ip=213.215.222.70; Received: from linux.lan.towertech.it (93-39-56-184.ip74.fastwebnet.it [93.39.56.184]) by elettra.colt-to.towertech.it (Postfix) with ESMTPSA id 48B9711673C; Thu, 21 Jan 2010 00:58:50 +0100 (CET) Date: Thu, 21 Jan 2010 00:58:49 +0100 From: Alessandro Zummo To: akpm@linux-foundation.org Cc: Julia Lawall , Daniel Mack , rtc-linux@googlegroups.com Subject: [rtc-linux] [PATCH 6/6] rtc-mxc.c: introduce missing kfree Message-ID: <20100121005849.1fa343a9@linux.lan.towertech.it> In-Reply-To: <20100120235227.18902.31224.stgit@linux.lan.towertech.it> References: <20100120235227.18902.31224.stgit@linux.lan.towertech.it> Organization: Tower Technologies X-Mailer: Sylpheed X-This-Is-A-Real-Message: Yes Mime-Version: 1.0 X-Virus-Scanned: clamav-milter 0.95.3 at elettra X-Virus-Status: Clean X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of a.zummo@towertech.it designates 213.215.222.70 as permitted sender) smtp.mail=a.zummo@towertech.it X-Original-Sender: azummo-google@towertech.it Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rtc-linux/t/94ecd7e6e5d87709 X-Message-Url: http://groups.google.com/group/rtc-linux/msg/d99d8eb3fc7b9825 Sender: rtc-linux@googlegroups.com List-Unsubscribe: , List-Subscribe: , From: Julia Lawall Error handling code following a kzalloc should free the allocated data. The semantic match that finds this 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 Signed-off-by: Alessandro Zummo Cc: Daniel Mack patch-name: 2-8-drivers-rtc-introduce-missing-kfree.patch patch-rev1: 98f7995fc38b62a0e182f3232aeddba05e065dee patch-rev2: 21f21ad391e7d62effad9d00153598c20ad89471 Acked-by: Daniel Mack --- drivers/rtc/rtc-mxc.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 6bd5072..2642e6b 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c @@ -396,8 +396,10 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) pdata->ioaddr = ioremap(res->start, resource_size(res)); clk = clk_get(&pdev->dev, "ckil"); - if (IS_ERR(clk)) - return PTR_ERR(clk); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + goto exit_free_pdata; + } rate = clk_get_rate(clk); clk_put(clk);