From: Roel Kluin Date: Tue, 22 Sep 2009 23:47:38 +0000 (-0700) Subject: drivers/video/console/newport_con.c: fix read outside array bounds X-Git-Tag: upstream/snapshot3+hdmi~17166 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7a595e98c3140f1271957aa742a6b84407620d4;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git drivers/video/console/newport_con.c: fix read outside array bounds It reads linetable[] before checking bounds of index, and ARRAY_SIZE is required because linetable[] are unsigned shorts. Signed-off-by: Roel Kluin Cc: Ralf Baechle Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index d31b203..3772433 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -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 |