]> git.sur5r.net Git - u-boot/commitdiff
NAND: Don't walk past end of oobfree[]
authorSandeep Paulraj <s-paulraj@ti.com>
Sat, 7 Nov 2009 19:25:18 +0000 (14:25 -0500)
committerScott Wood <scottwood@freescale.com>
Fri, 13 Nov 2009 22:56:16 +0000 (16:56 -0600)
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.
This syncs up with the kernel NAND driver.

Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
drivers/mtd/nand/nand_base.c

index 52b0c1a762da5a5c2ef890bc39ade59247d7ef00..cf032a622fb178c63f7fa705394468ff663554e7 100644 (file)
@@ -2871,7 +2871,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;