Patchwork [2.6.30-rc1] NAND: don't walk past end of oobfree[]

login
register
mail settings
Submitter David Brownell
Date April 7, 2009, 11:54 p.m.
Message ID <200904071654.55886.david-b@pacbell.net>
Download mbox | patch
Permalink /patch/25697/
State Accepted
Commit 81d19b04a865f9fcc0ca01b20be806169ff9efb3
Headers show

Comments

David Brownell - April 7, 2009, 11:54 p.m.
From: David Brownell <dbrownell@users.sourceforge.net>

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 4K 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>"
---
Seems appropriate for a 2.6.30-rc merge.

 drivers/mtd/nand/nand_base.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch

--- a/drivers/mtd/nand/nand_base.c
+++ b/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;