[PATCH 3/4] mtd: spi-nor: core: Fix erase type discovery for overlaid region
tkuw584924 at gmail.com
tkuw584924 at gmail.com
Fri Oct 2 01:18:01 EDT 2020
From: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
For overlaid regions, 'region->size' is assined to 'cmd->size' later in
spi_nor_init_erase_cmd() so 'erase->size' can be greater than 'len'.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
---
drivers/mtd/spi-nor/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0369d98b2d12..c7d5c86905fa 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1212,14 +1212,15 @@ spi_nor_find_best_erase_type(const struct spi_nor_erase_map *map,
erase = &map->erase_type[i];
+ /* Alignment is not mandatory for overlaid regions */
+ if (region->offset & SNOR_OVERLAID_REGION &&
+ region->size <= len)
+ return erase;
+
/* Don't erase more than what the user has asked for. */
if (erase->size > len)
continue;
- /* Alignment is not mandatory for overlaid regions */
- if (region->offset & SNOR_OVERLAID_REGION)
- return erase;
-
spi_nor_div_by_erase_size(erase, addr, &rem);
if (rem)
continue;
--
2.25.1
More information about the linux-mtd
mailing list