diff options
author | Matwey V. Kornilov <matwey@sai.msu.ru> | 2013-05-21 05:57:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-21 13:26:05 -0400 |
commit | dfc7b837c7f9f01f76511aa3eeea35232903e58f (patch) | |
tree | b68e1bd4ebeb5e5d20b2f92b53e9beb0d51a3d76 /drivers/tty | |
parent | 9d83e1807e6462ac5c4edb7eae96c69594e8c8ef (diff) |
tty: mxser: fix usage of opmode_ioaddr
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>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/mxser.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 71d6eb2c93b1..f97b196693c6 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c | |||
@@ -1618,8 +1618,12 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1618 | if (ip->type == PORT_16550A) | 1618 | if (ip->type == PORT_16550A) |
1619 | me->fifo[p] = 1; | 1619 | me->fifo[p] = 1; |
1620 | 1620 | ||
1621 | opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2); | 1621 | if (ip->board->chip_flag == MOXA_MUST_MU860_HWID) { |
1622 | opmode &= OP_MODE_MASK; | 1622 | opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2); |
1623 | opmode &= OP_MODE_MASK; | ||
1624 | } else { | ||
1625 | opmode = RS232_MODE; | ||
1626 | } | ||
1623 | me->iftype[p] = opmode; | 1627 | me->iftype[p] = opmode; |
1624 | mutex_unlock(&port->mutex); | 1628 | mutex_unlock(&port->mutex); |
1625 | } | 1629 | } |
@@ -1670,6 +1674,9 @@ static int mxser_ioctl(struct tty_struct *tty, | |||
1670 | return mxser_ioctl_special(cmd, argp); | 1674 | return mxser_ioctl_special(cmd, argp); |
1671 | 1675 | ||
1672 | if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) { | 1676 | if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) { |
1677 | if (info->board->chip_flag != MOXA_MUST_MU860_HWID) | ||
1678 | return -EFAULT; | ||
1679 | |||
1673 | int p; | 1680 | int p; |
1674 | unsigned long opmode; | 1681 | unsigned long opmode; |
1675 | static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f }; | 1682 | static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f }; |