summaryrefslogtreecommitdiff
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2012-07-14 18:31:27 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-16 23:58:12 +0400
commit6d31a88cb2e01d46c0cb74aa5da529e1f92ae3db (patch)
tree09ce3b070a845395f942b0ddeb8149514c0a7446 /drivers/tty/pty.c
parent467a3ca5cab64a16b5ec46ebb1895c84c280dcfe (diff)
downloadlinux-6d31a88cb2e01d46c0cb74aa5da529e1f92ae3db.tar.xz
tty: revert incorrectly applied lock patch
I sent GregKH this after the pre-requisites. He dropped the pre-requesites for good reason and unfortunately then applied this patch. Without this reverted you get random kernel memory corruption which will make bisecting anything between it and the properly applied patches a complete sod. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index a0ca0830cbcf..b50fc1c01415 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
wake_up_interruptible(&tty->read_wait);
wake_up_interruptible(&tty->write_wait);
tty->packet = 0;
- /* Review - krefs on tty_link ?? */
if (!tty->link)
return;
tty->link->packet = 0;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
mutex_unlock(&devpts_mutex);
}
#endif
- tty_unlock(tty);
+ tty_unlock();
tty_vhangup(tty->link);
- tty_lock(tty);
+ tty_lock();
}
}
@@ -616,26 +615,26 @@ static int ptmx_open(struct inode *inode, struct file *filp)
return retval;
/* find a device that is not in use. */
- mutex_lock(&devpts_mutex);
+ tty_lock();
index = devpts_new_index(inode);
- mutex_unlock(&devpts_mutex);
+ tty_unlock();
if (index < 0) {
retval = index;
goto err_file;
}
mutex_lock(&tty_mutex);
+ mutex_lock(&devpts_mutex);
tty = tty_init_dev(ptm_driver, index);
+ mutex_unlock(&devpts_mutex);
+ tty_lock();
+ mutex_unlock(&tty_mutex);
if (IS_ERR(tty)) {
retval = PTR_ERR(tty);
goto out;
}
- /* The tty returned here is locked so we can safely
- drop the mutex */
- mutex_unlock(&tty_mutex);
-
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
tty_add_file(tty, filp);
@@ -648,15 +647,15 @@ static int ptmx_open(struct inode *inode, struct file *filp)
if (retval)
goto err_release;
- tty_unlock(tty);
+ tty_unlock();
return 0;
err_release:
- tty_unlock(tty);
+ tty_unlock();
tty_release(inode, filp);
return retval;
out:
- mutex_unlock(&tty_mutex);
devpts_kill_index(inode, index);
+ tty_unlock();
err_file:
tty_free_file(filp);
return retval;