Skip to content

Commit

Permalink
serial: jsm: some off by one bugs
Browse files Browse the repository at this point in the history
"brd->nasync" amd "brd->maxports" are the same.  They hold the number of
filled out channels in the brd->channels[] array.  These tests should
be ">=" instead of ">" so that we don't read one element past the end.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Mar 26, 2015
1 parent 136debf commit a666b54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/tty/serial/jsm/jsm_cls.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static inline void cls_parse_isr(struct jsm_board *brd, uint port)
* verified in the interrupt routine.
*/

if (port > brd->nasync)
if (port >= brd->nasync)
return;

ch = brd->channels[port];
Expand Down
6 changes: 3 additions & 3 deletions drivers/tty/serial/jsm/jsm_neo.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)
if (!brd)
return;

if (port > brd->maxports)
if (port >= brd->maxports)
return;

ch = brd->channels[port];
Expand Down Expand Up @@ -840,7 +840,7 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
if (!brd)
return;

if (port > brd->maxports)
if (port >= brd->maxports)
return;

ch = brd->channels[port];
Expand Down Expand Up @@ -1180,7 +1180,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
*/

/* Verify the port is in range. */
if (port > brd->nasync)
if (port >= brd->nasync)
continue;

ch = brd->channels[port];
Expand Down

0 comments on commit a666b54

Please sign in to comment.