diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2009-04-21 22:51:20 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-06-05 12:39:09 -0400 |
commit | 81d19b04a865f9fcc0ca01b20be806169ff9efb3 (patch) | |
tree | 1d0a17203cf483b29ca45b0a35703f45198f18c2 | |
parent | 24430abc88c67e3df2f06c96a6ccd73bda4c92f0 (diff) |
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@users.sourceforge.net>
Cc: "Narnakaje, Snehaprabha" <nsnehaprabha@ti.com>"
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | 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 3d7ed432fa41..8c21b89d2d0c 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) | |||
2756 | * the out of band area | 2756 | * the out of band area |
2757 | */ | 2757 | */ |
2758 | chip->ecc.layout->oobavail = 0; | 2758 | chip->ecc.layout->oobavail = 0; |
2759 | for (i = 0; chip->ecc.layout->oobfree[i].length; i++) | 2759 | for (i = 0; chip->ecc.layout->oobfree[i].length |
2760 | && i < ARRAY_SIZE(chip->ecc.layout->oobfree); i++) | ||
2760 | chip->ecc.layout->oobavail += | 2761 | chip->ecc.layout->oobavail += |
2761 | chip->ecc.layout->oobfree[i].length; | 2762 | chip->ecc.layout->oobfree[i].length; |
2762 | mtd->oobavail = chip->ecc.layout->oobavail; | 2763 | mtd->oobavail = chip->ecc.layout->oobavail; |