]> git.karo-electronics.de Git - linux-beck.git/blobdiff - drivers/char/pty.c
tty: fix fu_list abuse
[linux-beck.git] / drivers / char / pty.c
index b640ef29be1c8334883a23f1aa138312064994ad..c350d01716bdace6ef510809e964a57c7129134b 100644 (file)
@@ -62,7 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
                if (tty->driver == ptm_driver)
                        devpts_pty_kill(tty->link);
 #endif
+               tty_unlock();
                tty_vhangup(tty->link);
+               tty_lock();
        }
 }
 
@@ -647,7 +649,7 @@ static const struct tty_operations pty_unix98_ops = {
  *             allocated_ptys_lock handles the list of free pty numbers
  */
 
-static int __ptmx_open(struct inode *inode, struct file *filp)
+static int ptmx_open(struct inode *inode, struct file *filp)
 {
        struct tty_struct *tty;
        int retval;
@@ -656,11 +658,14 @@ static int __ptmx_open(struct inode *inode, struct file *filp)
        nonseekable_open(inode, filp);
 
        /* find a device that is not in use. */
+       tty_lock();
        index = devpts_new_index(inode);
+       tty_unlock();
        if (index < 0)
                return index;
 
        mutex_lock(&tty_mutex);
+       tty_lock();
        tty = tty_init_dev(ptm_driver, index, 1);
        mutex_unlock(&tty_mutex);
 
@@ -670,34 +675,29 @@ static int __ptmx_open(struct inode *inode, struct file *filp)
        }
 
        set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
-       filp->private_data = tty;
-       file_move(filp, &tty->tty_files);
+
+       tty_add_file(tty, filp);
 
        retval = devpts_pty_new(inode, tty->link);
        if (retval)
                goto out1;
 
        retval = ptm_driver->ops->open(tty, filp);
-       if (!retval)
-               return 0;
+       if (retval)
+               goto out2;
 out1:
+       tty_unlock();
+       return retval;
+out2:
+       tty_unlock();
        tty_release(inode, filp);
        return retval;
 out:
        devpts_kill_index(inode, index);
+       tty_unlock();
        return retval;
 }
 
-static int ptmx_open(struct inode *inode, struct file *filp)
-{
-       int ret;
-
-       lock_kernel();
-       ret = __ptmx_open(inode, filp);
-       unlock_kernel();
-       return ret;
-}
-
 static struct file_operations ptmx_fops;
 
 static void __init unix98_pty_init(void)