public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org
Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
	Tudor Ambarus <tudor.ambarus@microchip.com>
Subject: Re: [PATCH] mtd: spi-nor: Reset nor->addr_width when SFDP parsing failed
Date: Mon, 5 Nov 2018 23:57:10 +0100	[thread overview]
Message-ID: <20181105235710.794efa36@bbrezillon> (raw)
In-Reply-To: <20181019090222.17592-1-boris.brezillon@bootlin.com>

On Fri, 19 Oct 2018 11:02:22 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:

> Commit 5390a8df769e ("mtd: spi-nor: add support to non-uniform SFDP SPI
> NOR flash memories") removed the 'nor->addr_width = 0;' statement when
> spi_nor_parse_sfdp() returns an error, thus leaving ->addr_width in an
> undefined state which can cause trouble when spi_nor_scan() checks its
> value.
> 
> Reported-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
> Fixes: 5390a8df769e ("mtd: spi-nor: add support to non-uniform SFDP SPI NOR flash memories")
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>

Queued to the fixes branch.

> ---
>  drivers/mtd/spi-nor/spi-nor.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 9407ca5f9443..3e54e31889c7 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -3250,12 +3250,14 @@ static int spi_nor_init_params(struct spi_nor *nor,
>  		memcpy(&sfdp_params, params, sizeof(sfdp_params));
>  		memcpy(&prev_map, &nor->erase_map, sizeof(prev_map));
>  
> -		if (spi_nor_parse_sfdp(nor, &sfdp_params))
> +		if (spi_nor_parse_sfdp(nor, &sfdp_params)) {
> +			nor->addr_width = 0;
>  			/* restore previous erase map */
>  			memcpy(&nor->erase_map, &prev_map,
>  			       sizeof(nor->erase_map));
> -		else
> +		} else {
>  			memcpy(params, &sfdp_params, sizeof(*params));
> +		}
>  	}
>  
>  	return 0;

      parent reply	other threads:[~2018-11-05 22:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19  9:02 [PATCH] mtd: spi-nor: Reset nor->addr_width when SFDP parsing failed Boris Brezillon
2018-10-19  9:35 ` Tudor Ambarus
2018-11-05 22:57 ` 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=20181105235710.794efa36@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@microchip.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