acrn-kernel/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
Kconfig
Makefile
atmel.c
catalyst.c
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
esmt.c
everspin.c
fujitsu.c
gigadevice.c
intel.c
issi.c
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
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
xmc.c