summaryrefslogtreecommitdiff
path: root/plat/socionext
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-06-15 09:32:12 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-06-15 09:39:37 +0900
commit3eba78d3c81700a548e123cd14c1f9258696a606 (patch)
tree706f3fa4cfb66d59410d48daa7fd993d38efd5f2 /plat/socionext
parent1502c4e157180613a736ff13c553e29cffd5168d (diff)
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>
Diffstat (limited to 'plat/socionext')
-rw-r--r--plat/socionext/uniphier/uniphier_nand.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/plat/socionext/uniphier/uniphier_nand.c b/plat/socionext/uniphier/uniphier_nand.c
index acf6a740..88f906c2 100644
--- a/plat/socionext/uniphier/uniphier_nand.c
+++ b/plat/socionext/uniphier/uniphier_nand.c
@@ -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);