From: "Jiandong Zheng" <jdzheng@broadcom.com>
To: "Julia Lawall" <julia@diku.dk>
Cc: "kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"Scott Branden" <sbranden@broadcom.com>,
"David Woodhouse" <dwmw2@infradead.org>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] drivers/mtd/nand/bcm_umi_nand.c: clean up error handling code
Date: Fri, 12 Aug 2011 14:32:11 -0700 [thread overview]
Message-ID: <4E459BDB.7020000@broadcom.com> (raw)
In-Reply-To: <1312964054-25266-1-git-send-email-julia@diku.dk>
On 8/10/2011 1:14 AM, Julia Lawall wrote:
> From: Julia Lawall<julia@diku.dk>
>
> Convert error handling code to use gotos. At the same time, this adds
> calls to kfree and iounmap in a few cases where they were overlooked.
>
> Signed-off-by: Julia Lawall<julia@diku.dk>
>
> ---
> drivers/mtd/nand/bcm_umi_nand.c | 33 ++++++++++++++++++---------------
> 1 file changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c
> index a8ae898..46b58d6 100644
> --- a/drivers/mtd/nand/bcm_umi_nand.c
> +++ b/drivers/mtd/nand/bcm_umi_nand.c
> @@ -374,16 +374,18 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
>
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>
> - if (!r)
> - return -ENXIO;
> + if (!r) {
> + err = -ENXIO;
> + goto out_free;
> + }
>
> /* map physical address */
> bcm_umi_io_base = ioremap(r->start, resource_size(r));
>
> if (!bcm_umi_io_base) {
> printk(KERN_ERR "ioremap to access BCM UMI NAND chip failed\n");
> - kfree(board_mtd);
> - return -EIO;
> + err = -EIO;
> + goto out_free;
> }
>
> /* Get pointer to private data */
> @@ -399,9 +401,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
> /* Initialize the NAND hardware. */
> if (bcm_umi_nand_inithw()< 0) {
> printk(KERN_ERR "BCM UMI NAND chip could not be initialized\n");
> - iounmap(bcm_umi_io_base);
> - kfree(board_mtd);
> - return -EIO;
> + err = -EIO;
> + goto out_unmap;
> }
>
> /* Set address of NAND IO lines */
> @@ -434,7 +435,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
> #if USE_DMA
> err = nand_dma_init();
> if (err != 0)
> - return err;
> + goto out_unmap;
> #endif
>
> /* Figure out the size of the device that we have.
> @@ -445,9 +446,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
> err = nand_scan_ident(board_mtd, 1, NULL);
> if (err) {
> printk(KERN_ERR "nand_scan failed: %d\n", err);
> - iounmap(bcm_umi_io_base);
> - kfree(board_mtd);
> - return err;
> + goto out_unmap;
> }
>
> /* Now that we know the nand size, we can setup the ECC layout */
> @@ -466,7 +465,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
> {
> printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n",
> board_mtd->writesize);
> - return -EINVAL;
> + err = -EINVAL;
> + goto out_unmap;
> }
> }
>
> @@ -483,9 +483,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
> err = nand_scan_tail(board_mtd);
> if (err) {
> printk(KERN_ERR "nand_scan failed: %d\n", err);
> - iounmap(bcm_umi_io_base);
> - kfree(board_mtd);
> - return err;
> + goto out_unmap;
> }
>
> /* Register the partitions */
> @@ -494,6 +492,11 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
>
> /* Return happy */
> return 0;
> +out_unmap:
> + iounmap(bcm_umi_io_base);
> +out_free:
> + kfree(board_mtd);
> + return err;
> }
>
> static int bcm_umi_nand_remove(struct platform_device *pdev)
>
>
Acked-by: Jiandong Zheng <jdzheng@broadcom.com>
next prev parent reply other threads:[~2011-08-12 21:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-10 8:14 [PATCH v3] drivers/mtd/nand/bcm_umi_nand.c: clean up error handling code Julia Lawall
2011-08-12 21:32 ` Jiandong Zheng [this message]
2011-08-19 12:08 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E459BDB.7020000@broadcom.com \
--to=jdzheng@broadcom.com \
--cc=dwmw2@infradead.org \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=sbranden@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox