nand: davinci: avoid out of bounds array access
The array bounds have to be checked before accessing the array element.
Identified by cppcheck.
Fixes: 67ac6ffaee
("mtd: nand: davinci: add opportunity to write keystone U-boot image")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
3380d1c131
commit
51443f57d8
@ -739,8 +739,8 @@ static void davinci_nand_init(struct nand_chip *nand)
|
||||
|
||||
layout = &nand_keystone_rbl_4bit_layout_oobfirst;
|
||||
layout->oobavail = 0;
|
||||
for (i = 0; layout->oobfree[i].length &&
|
||||
i < ARRAY_SIZE(layout->oobfree); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(layout->oobfree) &&
|
||||
layout->oobfree[i].length; i++)
|
||||
layout->oobavail += layout->oobfree[i].length;
|
||||
|
||||
nand->write_page = nand_davinci_write_page;
|
||||
|
Loading…
Reference in New Issue
Block a user