]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mtd: spi-nor: Reset nor->addr_width when SFDP parsing failed
authorBoris Brezillon <boris.brezillon@bootlin.com>
Fri, 19 Oct 2018 09:02:22 +0000 (11:02 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Mon, 5 Nov 2018 22:52:40 +0000 (23:52 +0100)
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>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
drivers/mtd/spi-nor/spi-nor.c

index 9407ca5f9443338d56a355fe0eadfa6641a429dc..3e54e31889c7b53bbba362a5bd497279dc91b128 100644 (file)
@@ -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;