Merge branch 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: serial: mfd: adjust the baud rate setting TTY: open/hangup race fixup TTY: don't allow reopen when ldisc is changing NET: wan/x25, fix ldisc->open retval TTY: ldisc, fix open flag handling serial8250: Mark console as CON_ANYTIME
This commit is contained in:
@@ -559,6 +559,9 @@ void __tty_hangup(struct tty_struct *tty)
|
||||
|
||||
tty_lock();
|
||||
|
||||
/* some functions below drop BTM, so we need this bit */
|
||||
set_bit(TTY_HUPPING, &tty->flags);
|
||||
|
||||
/* inuse_filps is protected by the single tty lock,
|
||||
this really needs to change if we want to flush the
|
||||
workqueue with the lock held */
|
||||
@@ -578,6 +581,10 @@ void __tty_hangup(struct tty_struct *tty)
|
||||
}
|
||||
spin_unlock(&tty_files_lock);
|
||||
|
||||
/*
|
||||
* it drops BTM and thus races with reopen
|
||||
* we protect the race by TTY_HUPPING
|
||||
*/
|
||||
tty_ldisc_hangup(tty);
|
||||
|
||||
read_lock(&tasklist_lock);
|
||||
@@ -615,7 +622,6 @@ void __tty_hangup(struct tty_struct *tty)
|
||||
tty->session = NULL;
|
||||
tty->pgrp = NULL;
|
||||
tty->ctrl_status = 0;
|
||||
set_bit(TTY_HUPPED, &tty->flags);
|
||||
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
|
||||
|
||||
/* Account for the p->signal references we killed */
|
||||
@@ -641,6 +647,7 @@ void __tty_hangup(struct tty_struct *tty)
|
||||
* can't yet guarantee all that.
|
||||
*/
|
||||
set_bit(TTY_HUPPED, &tty->flags);
|
||||
clear_bit(TTY_HUPPING, &tty->flags);
|
||||
tty_ldisc_enable(tty);
|
||||
|
||||
tty_unlock();
|
||||
@@ -1310,7 +1317,9 @@ static int tty_reopen(struct tty_struct *tty)
|
||||
{
|
||||
struct tty_driver *driver = tty->driver;
|
||||
|
||||
if (test_bit(TTY_CLOSING, &tty->flags))
|
||||
if (test_bit(TTY_CLOSING, &tty->flags) ||
|
||||
test_bit(TTY_HUPPING, &tty->flags) ||
|
||||
test_bit(TTY_LDISC_CHANGING, &tty->flags))
|
||||
return -EIO;
|
||||
|
||||
if (driver->type == TTY_DRIVER_TYPE_PTY &&
|
||||
|
@@ -454,6 +454,8 @@ static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld)
|
||||
/* BTM here locks versus a hangup event */
|
||||
WARN_ON(!tty_locked());
|
||||
ret = ld->ops->open(tty);
|
||||
if (ret)
|
||||
clear_bit(TTY_LDISC_OPEN, &tty->flags);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user