diff options
author | Alan Cox <alan@linux.intel.com> | 2012-05-29 13:45:01 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 10:42:13 -0700 |
commit | d3ca8b64b97ef4dc54d7bb0b88bbc01a1fca8cb9 (patch) | |
tree | 6205c4d17144485ff6ec3783463b0ed6e84bf831 /drivers/tty | |
parent | a01ee165a132fadb57659d26246e340d6ac53265 (diff) | |
download | linux-3.10-d3ca8b64b97ef4dc54d7bb0b88bbc01a1fca8cb9.tar.gz linux-3.10-d3ca8b64b97ef4dc54d7bb0b88bbc01a1fca8cb9.tar.bz2 linux-3.10-d3ca8b64b97ef4dc54d7bb0b88bbc01a1fca8cb9.zip |
pty: Fix lock inversion
The ptmx_open path takes the tty and devpts locks in the wrong order
because tty_init_dev locks and returns a locked tty. As far as I can
tell this is actually safe anyway because the tty being returned is new
so nobody can get a reference to lock it at this point.
However we don't even need the devpts lock at this point, it's only held
as a byproduct of the way the locks were pushe down.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/pty.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 59af3945ea8..65c7c62c7aa 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -633,7 +633,6 @@ static int ptmx_open(struct inode *inode, struct file *filp) mutex_unlock(&devpts_mutex); mutex_lock(&tty_mutex); - mutex_lock(&devpts_mutex); tty = tty_init_dev(ptm_driver, index); if (IS_ERR(tty)) { @@ -643,7 +642,6 @@ static int ptmx_open(struct inode *inode, struct file *filp) /* The tty returned here is locked so we can safely drop the mutex */ - mutex_unlock(&devpts_mutex); mutex_unlock(&tty_mutex); set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ |