mtd: nand: don't walk past end of oobfree[]
authorDavid Brownell <dbrownell@users.sourceforge.net>
Wed, 22 Apr 2009 02:51:20 +0000 (19:51 -0700)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 5 Jun 2009 16:39:09 +0000 (17:39 +0100)
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 4KiB page chips, it's fairly likely there *won't* be one.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: "Narnakaje, Snehaprabha" <nsnehaprabha@ti.com>"
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/nand_base.c

index 3d7ed432fa4157ec9d655c3354c4c1edc699ebc8..8c21b89d2d0c2a7ea79eccf0d9c840771c68a58a 100644 (file)
@@ -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;