summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2019-07-30 23:29:21 +0200
committerTom Rini <trini@konsulko.com>2019-07-31 13:08:07 -0400
commit51443f57d868dc622eb9ad367ac7f7a173ed986e (patch)
tree430bbea5f437115dd4feda445c1255b39c0dc2a7 /drivers
parent3380d1c131f376b4bd02d08a96e29af24c846601 (diff)
nand: davinci: avoid out of bounds array access
The array bounds have to be checked before accessing the array element. Identified by cppcheck. Fixes: 67ac6ffaeefb ("mtd: nand: davinci: add opportunity to write keystone U-boot image") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/raw/davinci_nand.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
index 33c2f16be8b..724bbee7526 100644
--- a/drivers/mtd/nand/raw/davinci_nand.c
+++ b/drivers/mtd/nand/raw/davinci_nand.c
@@ -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;