uniphier: fix memory over-run bug

Check the array index before the write.  This issue was found by a
static analysis tool.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
Masahiro Yamada 2017-06-15 09:32:12 +09:00
parent 1502c4e157
commit 3eba78d3c8

View file

@ -106,8 +106,9 @@ static int uniphier_nand_block_isbad(struct uniphier_nand *nand, int block)
is_bad = bbm != 0xff;
/* save the result for future re-use */
nand->bbt[block] = is_bad;
/* if possible, save the result for future re-use */
if (block < ARRAY_SIZE(nand->bbt))
nand->bbt[block] = is_bad;
if (is_bad)
WARN("found bad block at %d. skip.\n", block);