Commit 3af502b9 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

tty_lock: undo the old tty_lock use on the ctty

get_current_tty has its own consistent locking. That means a pile of the
tty lock cases are not needed. As get_current_tty also keeps a reference the
tty object lifetime means we can propogate the lock removal out.
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 22886ee9
...@@ -855,10 +855,11 @@ void disassociate_ctty(int on_exit) ...@@ -855,10 +855,11 @@ void disassociate_ctty(int on_exit)
*/ */
void no_tty(void) void no_tty(void)
{ {
/* FIXME: Review locking here. The tty_lock never covered any race
between a new association and proc_clear_tty but possible we need
to protect against this anyway */
struct task_struct *tsk = current; struct task_struct *tsk = current;
tty_lock();
disassociate_ctty(0); disassociate_ctty(0);
tty_unlock();
proc_clear_tty(tsk); proc_clear_tty(tsk);
} }
...@@ -1800,6 +1801,9 @@ int tty_release(struct inode *inode, struct file *filp) ...@@ -1800,6 +1801,9 @@ int tty_release(struct inode *inode, struct file *filp)
* *
* We cannot return driver and index like for the other nodes because * We cannot return driver and index like for the other nodes because
* devpts will not work then. It expects inodes to be from devpts FS. * devpts will not work then. It expects inodes to be from devpts FS.
*
* We need to move to returning a refcounted object from all the lookup
* paths including this one.
*/ */
static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp) static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)
{ {
...@@ -1816,6 +1820,7 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp) ...@@ -1816,6 +1820,7 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)
/* noctty = 1; */ /* noctty = 1; */
tty_kref_put(tty); tty_kref_put(tty);
/* FIXME: we put a reference and return a TTY! */ /* FIXME: we put a reference and return a TTY! */
/* This is only safe because the caller holds tty_mutex */
return tty; return tty;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment