TTY: get rid of BTM around devpts_*
authorJiri Slaby <jslaby@suse.cz>
Mon, 30 Jan 2012 20:14:32 +0000 (21:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Feb 2012 23:10:46 +0000 (15:10 -0800)
devpts operations are protected by inode mutexes and dentry
refcounting. There is no need to hold BTM.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/pty.c
drivers/tty/tty_io.c

index ddec9f3c33962d2a57c30a05ba7af9e3aa10a19f..39afd045f8efcd9e90962ce5cd9e731665b40af3 100644 (file)
@@ -54,8 +54,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        wake_up_interruptible(&tty->link->write_wait);
        if (tty->driver->subtype == PTY_TYPE_MASTER) {
                set_bit(TTY_OTHER_CLOSED, &tty->flags);
-               devpts_pty_kill(tty->link);
                tty_unlock();
+               devpts_pty_kill(tty->link);
                tty_vhangup(tty->link);
                tty_lock();
        }
@@ -613,9 +613,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
                return retval;
 
        /* find a device that is not in use. */
-       tty_lock();
        index = devpts_new_index(inode);
-       tty_unlock();
        if (index < 0) {
                retval = index;
                goto err_file;
@@ -650,8 +648,8 @@ err_release:
        tty_release(inode, filp);
        return retval;
 out:
-       devpts_kill_index(inode, index);
        tty_unlock();
+       devpts_kill_index(inode, index);
 err_file:
        tty_free_file(filp);
        return retval;
index 44736f9e61d71fa9d8ef58cc9bb57cf446f46dbe..ea7ebe22a16c87686d386ff0471dc1a96b8634e8 100644 (file)
@@ -1789,11 +1789,11 @@ int tty_release(struct inode *inode, struct file *filp)
         * the slots and preserving the termios structure.
         */
        release_tty(tty, idx);
+       tty_unlock();
 
        /* Make this pty number available for reallocation */
        if (devpts)
                devpts_kill_index(inode, idx);
-       tty_unlock();
        return 0;
 }