mtd: spinand: micron: fix division by zero
Subsystems (2)
PATCH 1/1 mtd: spinand: micron: fix division by zero
The ecc_step_size field ist not set at this point in the call tree, leading to a division by zero.
Read the step size from the mtd device ecc config instead.
--- drivers/mtd/nand/spi/micron.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/spi/micron.c +2 -1
@@ -106,9 +106,10 @@ static int micron_4_ooblayout_free(struct mtd_info *mtd, int section, struct mtd_oob_region *region) {struct spinand_device *spinand =mtd_to_spinand (mtd); +struct nand_device *nand =mtd_to_nanddev (mtd);if (section >= spinand->base.memorg.pagesize / - mtd->ecc_step_size) +nanddev_get_ecc_conf (nand)->step_size)return -ERANGE ;if (section) {
Signature · 6 lines
2.39.5 (Apple Git-154) ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerHi Micha,
Thanks for the patch, looks important.
Please fix Richard's address in next submission.
Quoted 1 line · Micha Ober
The
ecc_step_sizefield ist not set at this point
typo ^
Quoted 1 line
in the call tree, leading to a division by zero.
Definitely needs Fixes: + Cc: stable!
Quoted 1 line
Read the step size from the mtd device ecc config instead.
s/mtd device//
s/ecc config/ECC configuration/
drivers/mtd/nand/spi/micron.c static int micron_4_ooblayout_free(struct mtd_info *mtd, int section, · line 106
Quoted 12 lines
Signed-off-by Micha Ober <[email protected]>--- drivers/mtd/nand/spi/micron.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mtd/nand/spi/micron.c +0
-0@@ -106,9 +106,10 @@ static int micron_4_ooblayout_free(struct mtd_info *mtd, int section, struct mtd_oob_region *region)
What about the exact same situation in the .ecc() hook?
drivers/mtd/nand/spi/micron.c static int micron_4_ooblayout_free(struct mtd_info *mtd, int section, · line 115
Quoted 10 lines
drivers/mtd/nand/spi/micron.c +2
-1{struct spinand_device *spinand =mtd_to_spinand (mtd); +struct nand_device *nand =mtd_to_nanddev (mtd);if (section >= spinand->base.memorg.pagesize / - mtd->ecc_step_size) +nanddev_get_ecc_conf (nand)->step_size)return -ERANGE ;if (section) {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/