mtd: tests: fix read buffer overflows

Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
Roel Kluin
2009-07-31 16:21:01 +02:00
committed by David Woodhouse
parent 269c0ee663
commit c6f7e7beb9
2 changed files with 7 additions and 7 deletions

View File

@@ -512,7 +512,7 @@ static int __init mtd_oobtest_init(void)
goto out;
addr0 = 0;
for (i = 0; bbt[i] && i < ebcnt; ++i)
for (i = 0; i < ebcnt && bbt[i]; ++i)
addr0 += mtd->erasesize;
/* Attempt to write off end of OOB */