Skip to content

Commit 45a4c07

Browse files
committed
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()
2 parents b942791 + c4dc304 commit 45a4c07

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

drivers/tty/n_tty.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,12 +2413,17 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
24132413

24142414
poll_wait(file, &tty->read_wait, wait);
24152415
poll_wait(file, &tty->write_wait, wait);
2416+
if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2417+
mask |= POLLHUP;
24162418
if (input_available_p(tty, 1))
24172419
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+
}
24182425
if (tty->packet && tty->link->ctrl_status)
24192426
mask |= POLLPRI | POLLIN | POLLRDNORM;
2420-
if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2421-
mask |= POLLHUP;
24222427
if (tty_hung_up_p(file))
24232428
mask |= POLLHUP;
24242429
if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
8181
/* Set to highest baudrate supported */
8282
if (baud >= 1152000)
8383
baud = 921600;
84-
quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud);
84+
quot = (port->uartclk / (256 * baud)) + 1;
8585
}
8686

8787
/*

drivers/tty/serial/of_serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
158158
if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL))
159159
return -EBUSY;
160160

161-
info = kmalloc(sizeof(*info), GFP_KERNEL);
161+
info = kzalloc(sizeof(*info), GFP_KERNEL);
162162
if (info == NULL)
163163
return -ENOMEM;
164164

drivers/tty/serial/serial_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
363363
* The spd_hi, spd_vhi, spd_shi, spd_warp kludge...
364364
* Die! Die! Die!
365365
*/
366-
if (baud == 38400)
366+
if (try == 0 && baud == 38400)
367367
baud = altbaud;
368368

369369
/*

drivers/tty/tty_io.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,8 @@ int tty_release(struct inode *inode, struct file *filp)
17091709
int pty_master, tty_closing, o_tty_closing, do_sleep;
17101710
int idx;
17111711
char buf[64];
1712+
long timeout = 0;
1713+
int once = 1;
17121714

17131715
if (tty_paranoia_check(tty, inode, __func__))
17141716
return 0;
@@ -1789,11 +1791,18 @@ int tty_release(struct inode *inode, struct file *filp)
17891791
if (!do_sleep)
17901792
break;
17911793

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+
}
17941799
tty_unlock_pair(tty, o_tty);
17951800
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;
17971806
}
17981807

17991808
/*

drivers/tty/vt/consolemap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
539539

540540
/* Save original vc_unipagdir_loc in case we allocate a new one */
541541
p = *vc->vc_uni_pagedir_loc;
542+
543+
if (!p) {
544+
err = -EINVAL;
545+
546+
goto out_unlock;
547+
}
542548

543549
if (p->refcount > 1) {
544550
int j, k;
@@ -623,6 +629,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
623629
set_inverse_transl(vc, p, i); /* Update inverse translations */
624630
set_inverse_trans_unicode(vc, p);
625631

632+
out_unlock:
626633
console_unlock();
627634
return err;
628635
}

0 commit comments

Comments
 (0)