From patchwork Sat Jun 5 09:14:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wan ZongShun X-Patchwork-Id: 54744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (unknown [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8E0F0B7D1C for ; Sat, 5 Jun 2010 19:16:26 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OKpT0-0004Ba-MA; Sat, 05 Jun 2010 09:14:58 +0000 Received: from mail-pw0-f49.google.com ([209.85.160.49]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OKpSv-00046B-Ay; Sat, 05 Jun 2010 09:14:53 +0000 Received: by pwi2 with SMTP id 2so1006930pwi.36 for ; Sat, 05 Jun 2010 02:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=TitOpUIkasmHr0KjiorSjc5CyJQWw1QGJMmtJPZTObI=; b=KY7cwRbUYmXaubIb9fnk+p9ywgEqGzN9h3TiLkccbzhLO7aOSxD0Ds5TPrY0CNOLrB oue5oK1WSoHgDpIDqknyTKA1z9aPJz8gAsHHwuYY3zz8WGKggZ3+rUa+OGjm7C2QfPPI lAVrDLZNblV17SyC1ZVUoeyeiAzrUWjv+veKQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=tR6GjaT1KIr4GQMtpSha80JtlbyKmSNL3KyyTcYhHCzxk1ek97AJNF8EuAGvIO1eQs neBtSveFOxxkX+2tXGAFaMkWAXoFFjNwkU2N1uZh/VEcdkaMH0ais85423oaNN/NYb7U IIEmI/5nWoxLU8wzFEnv317tVYC3qeM+YCAWs= Received: by 10.142.196.21 with SMTP id t21mr8907810wff.237.1275729289935; Sat, 05 Jun 2010 02:14:49 -0700 (PDT) Received: from [192.168.1.4] ([58.39.231.84]) by mx.google.com with ESMTPS id 20sm1484654pzk.7.2010.06.05.02.14.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Jun 2010 02:14:49 -0700 (PDT) Message-ID: <4C0A157C.1050909@gmail.com> Date: Sat, 05 Jun 2010 17:14:36 +0800 From: Wan ZongShun User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: David Woodhouse , Eric Miao Subject: [PATCHv2 3/3] MTD/pxa: patch for error return value method of pxa2xx-flash X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100605_051453_481523_53042288 X-CRM114-Status: GOOD ( 14.78 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (mcuos.com[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-mtd , linux-arm-kernel 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: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch is to re-implement the 'pxa2xx-flash.c' error return value method of probe() and remove() function,the old return way can arouse the 'info' memory leak risk. This patch has been reviewed by Eric, according to his advice, I modify some wrong issues of previous patch and resend to maillist. Signed-off-by: Wan ZongShun --- drivers/mtd/maps/pxa2xx-flash.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c index b5bb1a4..e789358 100644 --- a/drivers/mtd/maps/pxa2xx-flash.c +++ b/drivers/mtd/maps/pxa2xx-flash.c @@ -78,7 +78,8 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev) if (!info->map.virt) { printk(KERN_WARNING "Failed to ioremap %s\n", info->map.name); - return -ENOMEM; + ret = -ENOMEM; + goto fail1; } info->map.cached = ioremap_cached(info->map.phys, info->map.size); @@ -97,10 +98,8 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev) info->mtd = do_map_probe(flash->map_name, &info->map); if (!info->mtd) { - iounmap((void *)info->map.virt); - if (info->map.cached) - iounmap(info->map.cached); - return -EIO; + ret = -EIO; + goto fail2; } info->mtd->owner = THIS_MODULE; @@ -124,6 +123,12 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); return 0; + +fail2: iounmap(info->map.virt); + if (info->map.cached) + iounmap(info->map.cached); +fail1: kfree(info); + return ret; } static int __devexit pxa2xx_flash_remove(struct platform_device *dev)