mtd: nand: don't walk past end of oobfree[]

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jun 5 14:59:04 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=81d19b04a865f9fcc0ca01b20be806169ff9efb3
Commit:     81d19b04a865f9fcc0ca01b20be806169ff9efb3
Parent:     24430abc88c67e3df2f06c96a6ccd73bda4c92f0
Author:     David Brownell <dbrownell at users.sourceforge.net>
AuthorDate: Tue Apr 21 19:51:20 2009 -0700
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jun 5 17:39:09 2009 +0100

    mtd: nand: don't walk past end of oobfree[]
    
    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 at users.sourceforge.net>
    Cc: "Narnakaje, Snehaprabha" <nsnehaprabha at ti.com>"
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 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 3d7ed43..8c21b89 100644
--- 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;



More information about the linux-mtd-cvs mailing list