Skip to content

Commit

Permalink
tty: mxser: fix usage of opmode_ioaddr
Browse files Browse the repository at this point in the history
mxser_port->opmode_ioaddr is initialized only for MOXA_MUST_MU860_HWID
chips, but no precautions have been undertaken to prevent reading and
writing to undefined port number.

Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Matwey V. Kornilov authored and Greg Kroah-Hartman committed May 21, 2013
1 parent 9d83e18 commit dfc7b83
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/tty/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1618,8 +1618,12 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
if (ip->type == PORT_16550A)
me->fifo[p] = 1;

opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2);
opmode &= OP_MODE_MASK;
if (ip->board->chip_flag == MOXA_MUST_MU860_HWID) {
opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2);
opmode &= OP_MODE_MASK;
} else {
opmode = RS232_MODE;
}
me->iftype[p] = opmode;
mutex_unlock(&port->mutex);
}
Expand Down Expand Up @@ -1670,6 +1674,9 @@ static int mxser_ioctl(struct tty_struct *tty,
return mxser_ioctl_special(cmd, argp);

if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
if (info->board->chip_flag != MOXA_MUST_MU860_HWID)
return -EFAULT;

int p;
unsigned long opmode;
static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
Expand Down

0 comments on commit dfc7b83

Please sign in to comment.