From patchwork Wed Aug 10 06:02:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 109336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E3238B71CA for ; Wed, 10 Aug 2011 16:02:41 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qr1s1-000693-0f; Wed, 10 Aug 2011 06:02:25 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qr1s0-0006Tm-Gf; Wed, 10 Aug 2011 06:02:24 +0000 Received: from mgw2.diku.dk ([130.225.96.92]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qr1rx-0006TG-Q6 for linux-mtd@lists.infradead.org; Wed, 10 Aug 2011 06:02:22 +0000 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id 774AA19BC34; Wed, 10 Aug 2011 08:02:19 +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 28807-16; Wed, 10 Aug 2011 08:02:14 +0200 (CEST) Received: from palace.topps.diku.dk (palace.ekstranet.diku.dk [192.38.115.202]) by mgw2.diku.dk (Postfix) with ESMTP id 641E019BC01; Wed, 10 Aug 2011 08:02:14 +0200 (CEST) From: Julia Lawall To: Jiandong Zheng Subject: [PATCH v2] drivers/mtd/nand/bcm_umi_nand.c: add missing kfree/iounmap Date: Wed, 10 Aug 2011 08:02:14 +0200 Message-Id: <1312956134-27553-1-git-send-email-julia@diku.dk> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110810_020221_981473_AEBF48D7 X-CRM114-Status: GOOD ( 11.20 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.8 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: David Woodhouse , linux-mtd@lists.infradead.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Scott Branden X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Julia Lawall Add kfree and iounmap systematically in all error handling code, including under #if. Signed-off-by: Julia Lawall --- drivers/mtd/nand/bcm_umi_nand.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c index a8ae898..8cb567b 100644 --- a/drivers/mtd/nand/bcm_umi_nand.c +++ b/drivers/mtd/nand/bcm_umi_nand.c @@ -374,8 +374,10 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev) r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) + if (!r) { + kfree(board_mtd); return -ENXIO; + } /* map physical address */ bcm_umi_io_base = ioremap(r->start, resource_size(r)); @@ -433,8 +435,11 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev) #if USE_DMA err = nand_dma_init(); - if (err != 0) + if (err != 0) { + iounmap(bcm_umi_io_base); + kfree(board_mtd); return err; + } #endif /* Figure out the size of the device that we have. @@ -466,6 +471,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev) { printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n", board_mtd->writesize); + iounmap(bcm_umi_io_base); + kfree(board_mtd); return -EINVAL; } }