Skip to contentSkip to conversation

mtd: nand: don't walk past end of oobfree[]

PATCH In review [email protected] 1 participant 1 message May 12, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 10/14 mtd: nand: don't walk past end of oobfree[]

From: David Brownell <[email protected]>

Resolve issue noted by Sneha: when computing oobavail from the list of free areas in the OOB, don't assume there will always be an unused slot at the end. With ECC_HW_SYNDROME and 4KB page chips, it's fairly likely there *won't* be one.

Cc "Narnakaje, Snehaprabha" <[email protected]>"
Cc David Woodhouse <[email protected]>

---

 drivers/mtd/nand/nand_base.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/nand_base.c renamed from drivers/mtd/nand/nand_base.c~mtd-nand-dont-walk-past-end-of-oobfree +2 -1
diff -puN drivers/mtd/nand/nand_base.c~mtd-nand-dont-walk-past-end-of-oobfree drivers/mtd/nand/nand_base.c
@@ -2756,7 +2756,8 @@ int nand_scan_tail(struct mtd_info *mtd)
 	 * the out of band area
 	 */
 	chip->ecc.layout->oobavail = 0;
-	for (i = 0; chip->ecc.layout->oobfree[i].length; i++)
+	for (i = 0; chip->ecc.layout->oobfree[i].length
+			&& i < ARRAY_SIZE(chip->ecc.layout->oobfree); i++)
 		chip->ecc.layout->oobavail +=
 			chip->ecc.layout->oobfree[i].length;
 	mtd->oobavail = chip->ecc.layout->oobavail;

_