public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [patch/RESEND 2.6.30-rc2 1/3] NAND: don't walk past end of oobfree[]
@ 2009-04-22  2:51 David Brownell
  2009-04-22  7:45 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: David Brownell @ 2009-04-22  2:51 UTC (permalink / raw)
  To: Linux MTD; +Cc: dwmw2, Thomas Gleixner, Narnakaje, Snehaprabha, Andrew Morton

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 4KB 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>"
---
RESEND refreshed 7-april version.
Still seems appropriate for a 2.6.30-rc merge.

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

--- 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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-22  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-22  2:51 [patch/RESEND 2.6.30-rc2 1/3] NAND: don't walk past end of oobfree[] David Brownell
2009-04-22  7:45 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox