[PATCH] mtd: spinand: micron: fix division by zero
Micha Ober
git at ober-mail.de
Sat Dec 28 07:41:06 PST 2024
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.
Signed-off-by: Micha Ober <git at ober-mail.de>
---
drivers/mtd/nand/spi/micron.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
index 12601bc4227a..7973996519d3 100644
--- a/drivers/mtd/nand/spi/micron.c
+++ b/drivers/mtd/nand/spi/micron.c
@@ -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) {
--
2.39.5 (Apple Git-154)
More information about the linux-mtd
mailing list