From: Takahiro Kuwano Date: Fri, 2 Oct 2020 05:17:59 +0000 (+0900) Subject: mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region X-Git-Tag: accepted/tizen/unified/20230118.172025~7837^2~2^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abdf5a5ef9652bad4d58058bc22ddf23543ba3e1;p=platform%2Fkernel%2Flinux-rpi.git mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region At the time spi_nor_region_check_overlay() is called, the erase types are sorted in ascending order of erase size. The 'erase_type' should be masked with 'BIT(erase[i].idx)' instead of 'BIT(i)'. Fixes: b038e8e3be72 ("mtd: spi-nor: parse SFDP Sector Map Parameter Table") Cc: stable@vger.kernel.org Signed-off-by: Takahiro Kuwano [ta: Add Fixes tag and Cc to stable] Signed-off-by: Tudor Ambarus Link: https://lore.kernel.org/r/fd90c40d5b626a1319a78fc2bcee79a8871d4d57.1601612872.git.Takahiro.Kuwano@infineon.com --- diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index 6ee7719..b3d44bd 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -788,7 +788,7 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region, int i; for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) { - if (!(erase_type & BIT(i))) + if (!(erase[i].size && erase_type & BIT(erase[i].idx))) continue; if (region->size & erase[i].size_mask) { spi_nor_region_mark_overlay(region);