[U-Boot] [PATCH] NAND: Don't walk past end of oobfree[]

s-paulraj at ti.com s-paulraj at ti.com
Fri Nov 6 16:44:55 CET 2009


From: Sandeep Paulraj <s-paulraj at ti.com>

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.

Signed-off-by: Sandeep Paulraj <s-paulraj at ti.com>
---
Applies to u-boot-nand-flash/next
This particular issue was found by TI while testing the DaVinci DM3xx
with new 4 KB page sized NAND devices.
I am going to attempt to send patches to sync up the MTD NAND driver
in u-boot with what is in the kernel.I am already using this feature
in our internal releases.
 drivers/mtd/nand/nand_base.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 30a3e9e..9263a69 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2868,7 +2868,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;
-- 
1.6.0.4



More information about the U-Boot mailing list