浏览代码

NAND: Don't walk past end of oobfree[]

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>
Sandeep Paulraj 15 年之前
父节点
当前提交
5df3c2b62c
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      drivers/mtd/nand/nand_base.c

+ 2 - 1
drivers/mtd/nand/nand_base.c

@@ -2871,7 +2871,8 @@ int nand_scan_tail(struct mtd_info *mtd)
 	 * the out of band area
 	 * the out of band area
 	 */
 	 */
 	chip->ecc.layout->oobavail = 0;
 	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->oobavail +=
 			chip->ecc.layout->oobfree[i].length;
 			chip->ecc.layout->oobfree[i].length;
 	mtd->oobavail = chip->ecc.layout->oobavail;
 	mtd->oobavail = chip->ecc.layout->oobavail;