Skip to content

Commit e397924

Browse files
Boris Brezillonambarus
authored andcommitted
mtd: spi-nor: Reset nor->addr_width when SFDP parsing failed
Commit 5390a8d ("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: 5390a8d ("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> (cherry picked from commit 90c31cb) Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent 1f9ce7e commit e397924

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,12 +3190,14 @@ static int spi_nor_init_params(struct spi_nor *nor,
31903190
memcpy(&sfdp_params, params, sizeof(sfdp_params));
31913191
memcpy(&prev_map, &nor->erase_map, sizeof(prev_map));
31923192

3193-
if (spi_nor_parse_sfdp(nor, &sfdp_params))
3193+
if (spi_nor_parse_sfdp(nor, &sfdp_params)) {
3194+
nor->addr_width = 0;
31943195
/* restore previous erase map */
31953196
memcpy(&nor->erase_map, &prev_map,
31963197
sizeof(nor->erase_map));
3197-
else
3198+
} else {
31983199
memcpy(params, &sfdp_params, sizeof(*params));
3200+
}
31993201
}
32003202

32013203
return 0;

0 commit comments

Comments
 (0)