Skip to content

Commit

Permalink
drivers/video/console/newport_con.c: fix read outside array bounds
Browse files Browse the repository at this point in the history
It reads linetable[] before checking bounds of index, and ARRAY_SIZE is
required because linetable[] are unsigned shorts.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Roel Kluin authored and Linus Torvalds committed Sep 23, 2009
1 parent db8df7b commit f7a595e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/video/console/newport_con.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static void newport_get_screensize(void)
}

newport_xsize = newport_ysize = 0;
for (i = 0; linetable[i + 1] && (i < sizeof(linetable)); i += 2) {
for (i = 0; i < ARRAY_SIZE(linetable) - 1 && linetable[i + 1]; i += 2) {
cols = 0;
newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
Expand Down

0 comments on commit f7a595e

Please sign in to comment.