From: Alan Cox Date: Wed, 19 Sep 2012 14:34:47 +0000 (+0100) Subject: pty: Fix locking bug on error path X-Git-Tag: Ubuntu-snapdragon-4.4.0-1050.54~13995^2~27 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=05fb79e45ee28b97a7cb74bd5ea3a88a8d13db1c;p=mirror_ubuntu-artful-kernel.git pty: Fix locking bug on error path We end up dropping the mutex twice on some errors. We don't want to do that. Reported-by: Fengguang Wu Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 2bace847eb39..a82b39939a9c 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -628,6 +628,7 @@ static int ptmx_open(struct inode *inode, struct file *filp) index = devpts_new_index(inode); if (index < 0) { retval = index; + mutex_unlock(&devpts_mutex); goto err_file; } @@ -667,7 +668,6 @@ out: mutex_unlock(&tty_mutex); devpts_kill_index(inode, index); err_file: - mutex_unlock(&devpts_mutex); tty_free_file(filp); return retval; }