Skip to content

Commit 81d19b0

Browse files
David BrownellDavid Woodhouse
authored andcommitted
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 <[email protected]> Cc: "Narnakaje, Snehaprabha" <[email protected]>" Signed-off-by: Artem Bityutskiy <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
1 parent 24430ab commit 81d19b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/mtd/nand/nand_base.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,8 @@ int nand_scan_tail(struct mtd_info *mtd)
27562756
* the out of band area
27572757
*/
27582758
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++)
27602761
chip->ecc.layout->oobavail +=
27612762
chip->ecc.layout->oobfree[i].length;
27622763
mtd->oobavail = chip->ecc.layout->oobavail;

0 commit comments

Comments
 (0)