diff mbox series

mtd: spi-nor: Initialize n_banks for spi_nor_generic_flash

Message ID 20230523073936.35203-1-mika.westerberg@linux.intel.com
State Not Applicable
Delegated to: Ambarus Tudor
Headers show
Series mtd: spi-nor: Initialize n_banks for spi_nor_generic_flash | expand

Commit Message

Mika Westerberg May 23, 2023, 7:39 a.m. UTC
If the flash chip in question is using spi_nor_generic_flash for
flash_info this results a division by zero during spi_nor_scan() because
its n_banks is 0.

Fix this by initializing n_banks for spi_nor_generic_flash to 1.

Fixes: 9d6c5d64f028 ("mtd: spi-nor: Introduce the concept of bank")
Cc: stable@vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/mtd/spi-nor/core.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Tudor Ambarus May 23, 2023, 9:04 a.m. UTC | #1
Thanks, Mika,

Miquel already queued a similar fix:
https://lore.kernel.org/linux-mtd/20230522155835.46756-1-miquel.raynal@bootlin.com/T/#m2d00f6d6bfb6298a6e8d81a4795d69db1e3c9505
cheers,
ta
On 5/23/23 08:39, Mika Westerberg wrote:
> If the flash chip in question is using spi_nor_generic_flash for
> flash_info this results a division by zero during spi_nor_scan() because
> its n_banks is 0.
> 
> Fix this by initializing n_banks for spi_nor_generic_flash to 1.
> 
> Fixes: 9d6c5d64f028 ("mtd: spi-nor: Introduce the concept of bank")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  drivers/mtd/spi-nor/core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 0bb0ad14a2fc..94fc4f6d0844 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2024,6 +2024,7 @@ static const struct flash_info spi_nor_generic_flash = {
>  	 */
>  	.page_size = 256,
>  	.parse_sfdp = true,
> +	.n_banks = 1,
>  };
>  
>  static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0bb0ad14a2fc..94fc4f6d0844 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2024,6 +2024,7 @@  static const struct flash_info spi_nor_generic_flash = {
 	 */
 	.page_size = 256,
 	.parse_sfdp = true,
+	.n_banks = 1,
 };
 
 static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,