mtd: spi-nor: fix flash probing
authorMichael Walle <mwalle@kernel.org>
Mon, 9 Sep 2024 07:28:54 +0000 (09:28 +0200)
committerPratyush Yadav <pratyush@kernel.org>
Sat, 14 Sep 2024 15:56:31 +0000 (17:56 +0200)
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 <jonathanh@nvidia.com>
Closes: https://lore.kernel.org/r/66c8ebb0-1324-4ad9-9926-8d4eb7e1e63a@nvidia.com/
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
Link: https://lore.kernel.org/r/20240909072854.812206-1-mwalle@kernel.org
drivers/mtd/spi-nor/core.c

index e0c4efc424f498dcb6d25bd24c12d1f1040783f9..9d6e85bf227b92d5ae847314f4d1869950b0bdaa 100644 (file)
@@ -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];
                        }