serial167: fix read buffer overflow
authorRoel Kluin <roel.kluin@gmail.com>
Thu, 1 Oct 2009 22:44:25 +0000 (15:44 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Oct 2009 23:11:16 +0000 (16:11 -0700)
commitf23fc156fb4294f678f1913a56da633fa57edb2d
treebc560880e9cf83542a3368963b429912ab218043
parent196b3167efd13a02cdd34acc1a12316b9f45f41d
serial167: fix read buffer overflow

Check whether index is within bounds before grabbing the element.

Also, since NR_PORTS is defined ARRAY_SIZE(cy_port), cy_port[NR_PORTS] is
out of bounds as well.

[akpm@linux-foundation.org: cleanup, remove (long) casts]
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/serial167.c