linux-stable/drivers/mtd/spi-nor
Tudor Ambarus 4095f4d922 mtd: spi-nor: Fix divide by zero for spi-nor-generic flashes
We failed to initialize n_banks for spi-nor-generic flashes, which
caused a devide by zero when computing the bank_size.

By default we consider that all chips have a single bank. Initialize
the default number of banks for spi-nor-generic flashes. Even if the
bug is fixed with this simple initialization, check the n_banks value
before dividing so that we make sure this kind of bug won't occur again
if some other struct instance is created uninitialized.

Suggested-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Reported-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217448
Fixes: 9d6c5d64f0 ("mtd: spi-nor: Introduce the concept of bank")
Link: https://lore.kernel.org/all/20230516225108.29194-1-todd.e.brandt@intel.com/
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Tested-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230518085440.2363676-1-tudor.ambarus@linaro.org
2023-05-26 19:40:32 +02:00
..
controllers mtd: Use of_property_read_bool() for boolean properties 2023-03-22 17:02:17 +01:00
Kconfig mtd: spi-nor: keep lock bits if they are non-volatile 2020-12-07 23:01:15 +05:30
Makefile mtd: spi-nor: expose internal parameters via debugfs 2022-05-09 16:55:22 +05:30
atmel.c mtd: spi-nor: atmel: unify function names 2022-02-25 09:44:31 +02:00
catalyst.c mtd: spi-nor: catalyst: unify function names 2022-02-25 09:44:31 +02:00
core.c mtd: spi-nor: Fix divide by zero for spi-nor-generic flashes 2023-05-26 19:40:32 +02:00
core.h Core MTD changes: 2023-04-25 17:23:42 -07:00
debugfs.c Core MTD changes: 2023-04-25 17:23:42 -07:00
eon.c mtd: spi-nor: support eon en25qh256a variant 2022-05-09 16:58:24 +05:30
esmt.c mtd: spi-nor: esmt: Use correct name of f25l32qa 2022-07-19 13:05:31 +03:00
everspin.c mtd: spi-nor: everspin: unify function names 2022-02-25 09:44:31 +02:00
fujitsu.c mtd: spi-nor: fujitsu: unify function names 2022-02-25 09:44:31 +02:00
gigadevice.c mtd: spi-nor: gigadevice: gd25q256: replace gd25q256_default_init with gd25q256_post_bfpt 2022-11-21 16:27:10 +02:00
intel.c mtd: spi-nor: intel: unify function names 2022-02-25 09:44:31 +02:00
issi.c mtd: spi-nor: sfdp: Rename BFPT_DWORD() macro to SFDP_DWORD() 2022-12-26 09:47:04 +02:00
macronix.c mtd: spi-nor: Set the 4-Byte Address Mode method based on SFDP data 2023-04-04 09:43:50 +03:00
micron-st.c mtd: spi-nor: Allow post_sfdp hook to return errors 2023-04-08 09:30:17 +03:00
otp.c mtd: spi-nor: Reorder the preparation vs. locking steps 2023-03-29 13:46:07 +03:00
sfdp.c mtd: spi-nor: sfdp: Add support for SCCR map for multi-chip device 2023-04-08 09:30:17 +03:00
sfdp.h mtd: spi-nor: Set the 4-Byte Address Mode method based on SFDP data 2023-04-04 09:43:50 +03:00
spansion.c mtd: spi-nor: spansion: make sure local struct does not contain garbage 2023-05-26 19:40:32 +02:00
sst.c mtd: spi-nor: Reorder the preparation vs. locking steps 2023-03-29 13:46:07 +03:00
swp.c mtd: spi-nor: Reorder the preparation vs. locking steps 2023-03-29 13:46:07 +03:00
sysfs.c mtd: spi-nor: sysfs: print JEDEC ID for generic flash driver 2022-11-21 15:37:16 +02:00
winbond.c mtd: spi-nor: Set the 4-Byte Address Mode method based on SFDP data 2023-04-04 09:43:50 +03:00
xilinx.c mtd: spi-nor: Introduce the concept of bank 2023-03-29 13:46:07 +03:00
xmc.c mtd: spi-nor: xmc: unify function names 2022-02-25 09:44:32 +02:00