aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Walle <[email protected]>2024-09-09 09:28:54 +0200
committerPratyush Yadav <[email protected]>2024-09-14 17:56:31 +0200
commitac5bfa968b60fba409942ab594ad98479b4e1223 (patch)
tree9507b299b19635aa5da57146cb74a0d2ce844ca3
parent1dc6cd4f94ad5c9432dc7c7a1e1ed6c52ec856ad (diff)
mtd: spi-nor: fix flash probing
Fix flash probing by name. Flash entries without a name are allowed since commit 15eb8303bb42 ("mtd: spi-nor: mark the flash name as obsolete"). But it was just until recently that a flash entry without a name was actually introduced. This triggers a bug in the legacy probe by name path. Skip entries without a name to fix it. Fixes: 2095e7da8049 ("mtd: spi-nor: spansion: Add support for S28HS256T") Reported-by: Jon Hunter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Tested-by: Jon Hunter <[email protected]> Signed-off-by: Michael Walle <[email protected]> Reviewed-by: Tudor Ambarus <[email protected]> Reviewed-by: Pratyush Yadav <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/[email protected]
-rw-r--r--drivers/mtd/spi-nor/core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index e0c4efc424f4..9d6e85bf227b 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3281,7 +3281,8 @@ static const struct flash_info *spi_nor_match_name(struct spi_nor *nor,
for (i = 0; i < ARRAY_SIZE(manufacturers); i++) {
for (j = 0; j < manufacturers[i]->nparts; j++) {
- if (!strcmp(name, manufacturers[i]->parts[j].name)) {
+ if (manufacturers[i]->parts[j].name &&
+ !strcmp(name, manufacturers[i]->parts[j].name)) {
nor->manufacturer = manufacturers[i];
return &manufacturers[i]->parts[j];
}