Skip to content

Commit

Permalink
tty: double unlock on error in ptmx_open()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Jul 12, 2012
1 parent 157a4b3 commit 79d7532
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/tty/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -659,7 +658,6 @@ static int ptmx_open(struct inode *inode, struct file *filp)
mutex_unlock(&tty_mutex);
devpts_kill_index(inode, index);
err_file:
mutex_unlock(&devpts_mutex);
tty_free_file(filp);
return retval;
}
Expand Down

0 comments on commit 79d7532

Please sign in to comment.