All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] tty: double unlock on error in ptmx_open()
@ 2012-07-11  6:40 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-07-11  6:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alan Cox, kernel-janitors

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>

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d855883..a0ca083 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;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [patch] tty: double unlock on error in ptmx_open()
@ 2012-07-11  6:40 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2012-07-11  6:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Alan Cox, kernel-janitors

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>

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d855883..a0ca083 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;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-11  6:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11  6:40 [patch] tty: double unlock on error in ptmx_open() Dan Carpenter
2012-07-11  6:40 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.