serial: 8250: Validate reg addr for Au1x00/RT288x i/o accessors
authorPeter Hurley <peter@hurleysoftware.com>
Mon, 9 Mar 2015 18:05:00 +0000 (14:05 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Mar 2015 21:21:08 +0000 (22:21 +0100)
commit509cb7dc07cc03c28c7995a9213a605c04675a58
treeed7b191357a6f1424d84a2daf1f0429db63b9c62
parent72a33aad476f9d4b1210dbf434f53eeea84909ab
serial: 8250: Validate reg addr for Au1x00/RT288x i/o accessors

Au1x00/RT2800+ hardware has an alternate register layout which is
remapped with lookup tables by the au_serial_in()/out() i/o accessors.
However, the h/w does not support the complete 8250 register set, and
accesses to unmapped registers cause out-of-bounds lookups. Further,
because the lookup tables are defined by designated initializers, the
tables may contain unmapped entries (although the current tables do not).

Declare fixed-size lookup tables with contiguous initialization for
the complete 8250 register map; unmapped registers are initialized to -1.
Validate the register index (ie., 'offset') is in the range [0, table size).
Return fixed value for unmapped register reads and ignore unmapped register
writes.

Reported-by: Mason <slash.tmp@free.fr>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Tested-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_core.c