Commit 45a4c0794d6e04e0fff49475fee54569a844e03d

Authored by Linus Torvalds

Merge tag 'tty-3.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial fixes from Greg KH:
 "Here are some tiny serial/tty fixes for 3.18-rc4 that resolve some
  reported issues"

* tag 'tty-3.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
  tty: Fix pty master poll() after slave closes v2
  serial: of-serial: fix uninitialized kmalloc variable
  tty/vt: don't set font mappings on vc not supporting this
  tty: serial: 8250_mtk: Fix quot calculation
  tty: Prevent "read/write wait queue active!" log flooding
  tty: Fix high cpu load if tty is unreleaseable
  serial: Fix divide-by-zero fault in uart_get_divisor()

Showing 6 changed files Side-by-side Diff

... ... @@ -2413,12 +2413,17 @@
2413 2413  
2414 2414 poll_wait(file, &tty->read_wait, wait);
2415 2415 poll_wait(file, &tty->write_wait, wait);
  2416 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
  2417 + mask |= POLLHUP;
2416 2418 if (input_available_p(tty, 1))
2417 2419 mask |= POLLIN | POLLRDNORM;
  2420 + else if (mask & POLLHUP) {
  2421 + tty_flush_to_ldisc(tty);
  2422 + if (input_available_p(tty, 1))
  2423 + mask |= POLLIN | POLLRDNORM;
  2424 + }
2418 2425 if (tty->packet && tty->link->ctrl_status)
2419 2426 mask |= POLLPRI | POLLIN | POLLRDNORM;
2420   - if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2421   - mask |= POLLHUP;
2422 2427 if (tty_hung_up_p(file))
2423 2428 mask |= POLLHUP;
2424 2429 if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {
drivers/tty/serial/8250/8250_mtk.c
... ... @@ -81,7 +81,7 @@
81 81 /* Set to highest baudrate supported */
82 82 if (baud >= 1152000)
83 83 baud = 921600;
84   - quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud);
  84 + quot = (port->uartclk / (256 * baud)) + 1;
85 85 }
86 86  
87 87 /*
drivers/tty/serial/of_serial.c
... ... @@ -158,7 +158,7 @@
158 158 if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL))
159 159 return -EBUSY;
160 160  
161   - info = kmalloc(sizeof(*info), GFP_KERNEL);
  161 + info = kzalloc(sizeof(*info), GFP_KERNEL);
162 162 if (info == NULL)
163 163 return -ENOMEM;
164 164  
drivers/tty/serial/serial_core.c
... ... @@ -363,7 +363,7 @@
363 363 * The spd_hi, spd_vhi, spd_shi, spd_warp kludge...
364 364 * Die! Die! Die!
365 365 */
366   - if (baud == 38400)
  366 + if (try == 0 && baud == 38400)
367 367 baud = altbaud;
368 368  
369 369 /*
drivers/tty/tty_io.c
... ... @@ -1709,6 +1709,8 @@
1709 1709 int pty_master, tty_closing, o_tty_closing, do_sleep;
1710 1710 int idx;
1711 1711 char buf[64];
  1712 + long timeout = 0;
  1713 + int once = 1;
1712 1714  
1713 1715 if (tty_paranoia_check(tty, inode, __func__))
1714 1716 return 0;
1715 1717  
... ... @@ -1789,11 +1791,18 @@
1789 1791 if (!do_sleep)
1790 1792 break;
1791 1793  
1792   - printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
1793   - __func__, tty_name(tty, buf));
  1794 + if (once) {
  1795 + once = 0;
  1796 + printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
  1797 + __func__, tty_name(tty, buf));
  1798 + }
1794 1799 tty_unlock_pair(tty, o_tty);
1795 1800 mutex_unlock(&tty_mutex);
1796   - schedule();
  1801 + schedule_timeout_killable(timeout);
  1802 + if (timeout < 120 * HZ)
  1803 + timeout = 2 * timeout + 1;
  1804 + else
  1805 + timeout = MAX_SCHEDULE_TIMEOUT;
1797 1806 }
1798 1807  
1799 1808 /*
drivers/tty/vt/consolemap.c
... ... @@ -539,6 +539,12 @@
539 539  
540 540 /* Save original vc_unipagdir_loc in case we allocate a new one */
541 541 p = *vc->vc_uni_pagedir_loc;
  542 +
  543 + if (!p) {
  544 + err = -EINVAL;
  545 +
  546 + goto out_unlock;
  547 + }
542 548  
543 549 if (p->refcount > 1) {
544 550 int j, k;
... ... @@ -623,6 +629,7 @@
623 629 set_inverse_transl(vc, p, i); /* Update inverse translations */
624 630 set_inverse_trans_unicode(vc, p);
625 631  
  632 +out_unlock:
626 633 console_unlock();
627 634 return err;
628 635 }