All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	Han Xu <han.xu@nxp.com>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <kernel@pengutronix.de>,
	Leonard Crestez <leonard.crestez@nxp.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: Re: [PATCH 1/2] mtd: nand: gpmi: Fix gpmi_nand_init() error path
Date: Mon, 15 May 2017 21:40:13 +0200	[thread overview]
Message-ID: <20170515214013.580e161a@bbrezillon> (raw)
In-Reply-To: <1491813318-4417-1-git-send-email-boris.brezillon@free-electrons.com>

On Mon, 10 Apr 2017 10:35:17 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> The GPMI driver is wrongly assuming that nand_release() can safely be
> called on an uninitialized/unregistered NAND device.
> 
> Add a new err_nand_cleanup label in the error path and only execute if
> nand_scan_tail() succeeded.
> 
> Note that we now call nand_cleanup() instead of nand_release()
> (nand_release() is actually grouping the mtd_device_unregister() and
> nand_cleanup() in one call) because there's no point in trying to
> unregister a device that has never been registered.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Applied both to nand/next.

> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index d52139635b67..92279a0d52f1 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -2048,18 +2048,20 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
>  
>  	ret = nand_boot_init(this);
>  	if (ret)
> -		goto err_out;
> +		goto err_nand_cleanup;
>  	ret = chip->scan_bbt(mtd);
>  	if (ret)
> -		goto err_out;
> +		goto err_nand_cleanup;
>  
>  	ret = mtd_device_register(mtd, NULL, 0);
>  	if (ret)
> -		goto err_out;
> +		goto err_nand_cleanup;
>  	return 0;
>  
> +err_nand_cleanup:
> +	nand_cleanup(chip);
>  err_out:
> -	gpmi_nand_exit(this);
> +	gpmi_free_dma_buffer(this);
>  	return ret;
>  }
>  

      parent reply	other threads:[~2017-05-15 19:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10  8:35 [PATCH 1/2] mtd: nand: gpmi: Fix gpmi_nand_init() error path Boris Brezillon
2017-04-10  8:35 ` [PATCH 2/2] mtd: nand: gpmi: Kill gpmi_nand_exit() Boris Brezillon
2017-04-15 14:58   ` Marek Vasut
2017-04-17 16:55     ` Han Xu
2017-04-15 14:58 ` [PATCH 1/2] mtd: nand: gpmi: Fix gpmi_nand_init() error path Marek Vasut
2017-04-17 16:50   ` Han Xu
2017-05-15 19:40 ` Boris Brezillon [this message]

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=20170515214013.580e161a@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dwmw2@infradead.org \
    --cc=han.xu@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=leonard.crestez@nxp.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=shawnguo@kernel.org \
    --cc=yamada.masahiro@socionext.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.