linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	linux-kernel@vger.kernel.org, Marek Vasut <marek.vasut@gmail.com>,
	linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] mtd: gpio_flash: add error handling for ioremap_nocache
Date: Fri, 22 Jun 2018 00:21:09 +0200	[thread overview]
Message-ID: <20180622002109.0cffb249@bbrezillon> (raw)
In-Reply-To: <1528773302-37265-1-git-send-email-jiazhouyang09@gmail.com>

On Tue, 12 Jun 2018 11:15:00 +0800
Zhouyang Jia <jiazhouyang09@gmail.com> wrote:

> When ioremap_nocache fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling ioremap_nocache.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
>  drivers/mtd/maps/gpio-addr-flash.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
> index 385305e..7fbba02 100644
> --- a/drivers/mtd/maps/gpio-addr-flash.c
> +++ b/drivers/mtd/maps/gpio-addr-flash.c
> @@ -242,6 +242,9 @@ static int gpio_flash_probe(struct platform_device *pdev)
>  	state->map.phys       = NO_XIP;
>  	state->map.map_priv_1 = (unsigned long)state;
>  
> +	if (!state->map.virt)
> +		return -ENOMEM;

Please move the test just after the ioremap_nocache() call. Also, I see
that iounmap() is never called. Probably a good opportunity to switch
to devm_ funcs.

> +
>  	platform_set_drvdata(pdev, state);
>  
>  	i = 0;

  reply	other threads:[~2018-06-21 22:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12  3:15 [PATCH] mtd: gpio_flash: add error handling for ioremap_nocache Zhouyang Jia
2018-06-21 22:21 ` Boris Brezillon [this message]
2018-06-22  1:52 ` [PATCH v2] " Zhouyang Jia
2018-07-07  9:59   ` Boris Brezillon

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=20180622002109.0cffb249@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=jiazhouyang09@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /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;
as well as URLs for NNTP newsgroup(s).