diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2014-11-05 20:13:00 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-06 05:44:43 +0300 |
commit | 7ffb6da93c383a71b7f2d29d70cd420faa1ddeee (patch) | |
tree | 8468e693d64e8da711e78a9916b09d9fde817397 /drivers/tty/tty_io.c | |
parent | 359b9fb5c4f0d49f7062356f55073a169f36e29d (diff) | |
download | linux-7ffb6da93c383a71b7f2d29d70cd420faa1ddeee.tar.xz |
tty: Simplify tty_release() state checks
The local o_tty variable in tty_release() is now accessed only
when closing the pty master.
Set o_tty to slave pty when closing pty master, otherwise NULL;
use o_tty != NULL as replacement for pty_master.
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r-- | drivers/tty/tty_io.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index e927650a98fd..bd7cde3c56ef 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1759,8 +1759,8 @@ static int tty_release_checks(struct tty_struct *tty, int idx) int tty_release(struct inode *inode, struct file *filp) { struct tty_struct *tty = file_tty(filp); - struct tty_struct *o_tty; - int pty_master, do_sleep, final; + struct tty_struct *o_tty = NULL; + int do_sleep, final; int idx; char buf[64]; @@ -1773,10 +1773,9 @@ int tty_release(struct inode *inode, struct file *filp) __tty_fasync(-1, filp, 0); idx = tty->index; - pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && - tty->driver->subtype == PTY_TYPE_MASTER); - /* Review: parallel close */ - o_tty = tty->link; + if (tty->driver->type == TTY_DRIVER_TYPE_PTY && + tty->driver->subtype == PTY_TYPE_MASTER) + o_tty = tty->link; if (tty_release_checks(tty, idx)) { tty_unlock(tty); @@ -1820,7 +1819,7 @@ int tty_release(struct inode *inode, struct file *filp) do_sleep++; } } - if (pty_master && o_tty->count <= 1) { + if (o_tty && o_tty->count <= 1) { if (waitqueue_active(&o_tty->read_wait)) { wake_up_poll(&o_tty->read_wait, POLLIN); do_sleep++; @@ -1838,7 +1837,7 @@ int tty_release(struct inode *inode, struct file *filp) schedule(); } - if (pty_master) { + if (o_tty) { if (--o_tty->count < 0) { printk(KERN_WARNING "%s: bad pty slave count (%d) for %s\n", __func__, o_tty->count, tty_name(o_tty, buf)); @@ -1872,13 +1871,13 @@ int tty_release(struct inode *inode, struct file *filp) if (!tty->count) { read_lock(&tasklist_lock); session_clear_tty(tty->session); - if (pty_master) + if (o_tty) session_clear_tty(o_tty->session); read_unlock(&tasklist_lock); } /* check whether both sides are closing ... */ - final = !tty->count && !(pty_master && o_tty->count); + final = !tty->count && !(o_tty && o_tty->count); tty_unlock_pair(tty, o_tty); /* At this point, the tty->count == 0 should ensure a dead tty |