diff options
author | Alan Cox <alan@linux.intel.com> | 2012-05-03 17:21:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-04 19:47:38 -0400 |
commit | 3af502b96649ccb7462da73b0cca446c8384b155 (patch) | |
tree | 8d2f1a77e25354c69d61192e544bedb681cbb80e /drivers/tty/tty_io.c | |
parent | 22886ee96895b7a9f9d06da4dc9420b61b4ef1f7 (diff) |
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: Alan Cox <alan@linux.intel.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 | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index d939bd705c71..b425c79675ad 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -855,10 +855,11 @@ void disassociate_ctty(int on_exit) | |||
855 | */ | 855 | */ |
856 | void no_tty(void) | 856 | void no_tty(void) |
857 | { | 857 | { |
858 | /* FIXME: Review locking here. The tty_lock never covered any race | ||
859 | between a new association and proc_clear_tty but possible we need | ||
860 | to protect against this anyway */ | ||
858 | struct task_struct *tsk = current; | 861 | struct task_struct *tsk = current; |
859 | tty_lock(); | ||
860 | disassociate_ctty(0); | 862 | disassociate_ctty(0); |
861 | tty_unlock(); | ||
862 | proc_clear_tty(tsk); | 863 | proc_clear_tty(tsk); |
863 | } | 864 | } |
864 | 865 | ||
@@ -1800,6 +1801,9 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1800 | * | 1801 | * |
1801 | * We cannot return driver and index like for the other nodes because | 1802 | * We cannot return driver and index like for the other nodes because |
1802 | * devpts will not work then. It expects inodes to be from devpts FS. | 1803 | * devpts will not work then. It expects inodes to be from devpts FS. |
1804 | * | ||
1805 | * We need to move to returning a refcounted object from all the lookup | ||
1806 | * paths including this one. | ||
1803 | */ | 1807 | */ |
1804 | static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp) | 1808 | static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp) |
1805 | { | 1809 | { |
@@ -1816,6 +1820,7 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp) | |||
1816 | /* noctty = 1; */ | 1820 | /* noctty = 1; */ |
1817 | tty_kref_put(tty); | 1821 | tty_kref_put(tty); |
1818 | /* FIXME: we put a reference and return a TTY! */ | 1822 | /* FIXME: we put a reference and return a TTY! */ |
1823 | /* This is only safe because the caller holds tty_mutex */ | ||
1819 | return tty; | 1824 | return tty; |
1820 | } | 1825 | } |
1821 | 1826 | ||