summaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorDan Carpenter2012-07-11 08:40:40 +0200
committerGreg Kroah-Hartman2012-07-12 23:27:08 +0200
commit79d753209245de3d6f02480535a8f5cf21ad02f7 (patch)
treec2aa38c82c6b067e7ca9ae7d40abbc81f51ce124 /drivers/tty/pty.c
parenttty: keyboard.c: Remove locking from vt_get_leds. (diff)
downloadkernel-qcow2-linux-79d753209245de3d6f02480535a8f5cf21ad02f7.tar.gz
kernel-qcow2-linux-79d753209245de3d6f02480535a8f5cf21ad02f7.tar.xz
kernel-qcow2-linux-79d753209245de3d6f02480535a8f5cf21ad02f7.zip
tty: double unlock on error in ptmx_open()
The problem here is that we called mutex_unlock(&devpts_mutex) on the error path when we weren't holding the lock. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d8558834ce57..a0ca0830cbcf 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -618,13 +618,12 @@ static int ptmx_open(struct inode *inode, struct file *filp)
/* find a device that is not in use. */
mutex_lock(&devpts_mutex);
index = devpts_new_index(inode);
+ mutex_unlock(&devpts_mutex);
if (index < 0) {
retval = index;
goto err_file;
}
- mutex_unlock(&devpts_mutex);
-
mutex_lock(&tty_mutex);
tty = tty_init_dev(ptm_driver, index);
@@ -659,7 +658,6 @@ out:
mutex_unlock(&tty_mutex);
devpts_kill_index(inode, index);
err_file:
- mutex_unlock(&devpts_mutex);
tty_free_file(filp);
return retval;
}