aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-10-18 16:26:36 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-22 19:50:53 -0400
commit3383427a7b325e50af03d6f42b9587ca66d941a6 (patch)
tree851bfb2010afac779c62112e82c4bff599923349 /drivers
parentb91939f528fa80e95a7e9592425dd1026d159b2a (diff)
TTY: n_tty, remove bogus checks
* BUG_ON(!tty) in n_tty_set_termios -- it cannot be called with tty == NULL. It is called from two call sites. First, from n_tty_open where we have a valid tty. Second, as ld->ops->set_termios from tty_set_termios. But there we have a valid tty too. * if (!tty) in n_tty_open -- why would the TTY layer call ldisc's open with an invalid TTY? No it indeed does not. All call sites have a tty and dereference that. * BUG_ON(!tty->read_buf) in n_tty_read -- this used to be a valid check. The ldisc handling was broken some time ago when I added the check to ensure everything is OK. It still can catch the case, but no later than we move the buffer to ldisc data. Then there will be no read_buf in tty_struct, i.e. nothing to check for. * if (!tty->read_buf) in n_tty_receive_buf -- this should never happen. All callers of ldisc->ops->receive_ops should hold a reference to an ldisc and close (which frees read_buf) cannot be called until the reference is dropped. * if (WARN_ON(!tty->read_buf)) in n_tty_read -- the same as in the previous case. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/n_tty.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index f27289d910b2..ceae0744cbb8 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1375,9 +1375,6 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1375 char buf[64]; 1375 char buf[64];
1376 unsigned long cpuflags; 1376 unsigned long cpuflags;
1377 1377
1378 if (!tty->read_buf)
1379 return;
1380
1381 if (tty->real_raw) { 1378 if (tty->real_raw) {
1382 spin_lock_irqsave(&tty->read_lock, cpuflags); 1379 spin_lock_irqsave(&tty->read_lock, cpuflags);
1383 i = min(N_TTY_BUF_SIZE - tty->read_cnt, 1380 i = min(N_TTY_BUF_SIZE - tty->read_cnt,
@@ -1471,7 +1468,6 @@ int is_ignored(int sig)
1471static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 1468static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1472{ 1469{
1473 int canon_change = 1; 1470 int canon_change = 1;
1474 BUG_ON(!tty);
1475 1471
1476 if (old) 1472 if (old)
1477 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON; 1473 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON;
@@ -1579,9 +1575,6 @@ static void n_tty_close(struct tty_struct *tty)
1579 1575
1580static int n_tty_open(struct tty_struct *tty) 1576static int n_tty_open(struct tty_struct *tty)
1581{ 1577{
1582 if (!tty)
1583 return -EINVAL;
1584
1585 /* These are ugly. Currently a malloc failure here can panic */ 1578 /* These are ugly. Currently a malloc failure here can panic */
1586 tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 1579 tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
1587 tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 1580 tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
@@ -1736,10 +1729,6 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
1736 int packet; 1729 int packet;
1737 1730
1738do_it_again: 1731do_it_again:
1739
1740 if (WARN_ON(!tty->read_buf))
1741 return -EAGAIN;
1742
1743 c = job_control(tty, file); 1732 c = job_control(tty, file);
1744 if (c < 0) 1733 if (c < 0)
1745 return c; 1734 return c;
@@ -1825,7 +1814,6 @@ do_it_again:
1825 /* FIXME: does n_tty_set_room need locking ? */ 1814 /* FIXME: does n_tty_set_room need locking ? */
1826 n_tty_set_room(tty); 1815 n_tty_set_room(tty);
1827 timeout = schedule_timeout(timeout); 1816 timeout = schedule_timeout(timeout);
1828 BUG_ON(!tty->read_buf);
1829 continue; 1817 continue;
1830 } 1818 }
1831 __set_current_state(TASK_RUNNING); 1819 __set_current_state(TASK_RUNNING);