[PATCH v4 02/28] mtd: spi-nor: Complete error rollback on sfdp parsing failure
Miquel Raynal <[email protected]> Tue, 04 Aug 2026 16:04:24 +0200
| Newsgroups | gmane.linux.kernel,gmane.linux.drivers.mtd |
|---|---|
| Message-ID | <20260804-winbond-v7-1-spi-nor-jv-cleanup-v4-2-ee3445066e4e@bootlin.com> |
Make sure to rollback all changes induced by SFDP parsing in case of failure, which means also resetting nor->flags and nor->cmd_ext_type. Signed-off-by: Miquel Raynal <[email protected]> --- drivers/mtd/spi-nor/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index ccf4396cdcd0..c39c6833c9a4 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3063,12 +3063,17 @@ static int spi_nor_late_init_params(struct spi_nor *nor) static void spi_nor_sfdp_init_params_deprecated(struct spi_nor *nor) { struct spi_nor_flash_parameter sfdp_params; + enum spi_nor_cmd_ext cmd_ext_type; + u32 flags; memcpy(&sfdp_params, nor->params, sizeof(sfdp_params)); + cmd_ext_type = nor->cmd_ext_type; + flags = nor->flags; if (spi_nor_parse_sfdp(nor)) { memcpy(nor->params, &sfdp_params, sizeof(*nor->params)); - nor->flags &= ~SNOR_F_4B_OPCODES; + nor->cmd_ext_type = cmd_ext_type; + nor->flags = flags; } } -- 2.54.0