]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
drivers/video/console/newport_con.c: fix read outside array bounds
authorRoel Kluin <roel.kluin@gmail.com>
Tue, 22 Sep 2009 23:47:38 +0000 (16:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Sep 2009 14:39:56 +0000 (07:39 -0700)
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>
drivers/video/console/newport_con.c

index d31b203bf6549bdb94b337e9f28f7265d8b544e4..3772433c49d16da2045b22939d54fd3b6139287c 100644 (file)
@@ -216,7 +216,7 @@ static void newport_get_screensize(void)
        }
 
        newport_xsize = newport_ysize = 0;
        }
 
        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 |
                cols = 0;
                newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
                npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |