aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2012-07-14 10:31:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-16 15:58:12 -0400
commit6d31a88cb2e01d46c0cb74aa5da529e1f92ae3db (patch)
tree09ce3b070a845395f942b0ddeb8149514c0a7446 /drivers/tty/pty.c
parent467a3ca5cab64a16b5ec46ebb1895c84c280dcfe (diff)
tty: revert incorrectly applied lock patch
I sent GregKH this after the pre-requisites. He dropped the pre-requesites for good reason and unfortunately then applied this patch. Without this reverted you get random kernel memory corruption which will make bisecting anything between it and the properly applied patches a complete sod. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index a0ca0830cbcf..b50fc1c01415 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -47,7 +47,6 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
47 wake_up_interruptible(&tty->read_wait); 47 wake_up_interruptible(&tty->read_wait);
48 wake_up_interruptible(&tty->write_wait); 48 wake_up_interruptible(&tty->write_wait);
49 tty->packet = 0; 49 tty->packet = 0;
50 /* Review - krefs on tty_link ?? */
51 if (!tty->link) 50 if (!tty->link)
52 return; 51 return;
53 tty->link->packet = 0; 52 tty->link->packet = 0;
@@ -63,9 +62,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
63 mutex_unlock(&devpts_mutex); 62 mutex_unlock(&devpts_mutex);
64 } 63 }
65#endif 64#endif
66 tty_unlock(tty); 65 tty_unlock();
67 tty_vhangup(tty->link); 66 tty_vhangup(tty->link);
68 tty_lock(tty); 67 tty_lock();
69 } 68 }
70} 69}
71 70
@@ -616,26 +615,26 @@ static int ptmx_open(struct inode *inode, struct file *filp)
616 return retval; 615 return retval;
617 616
618 /* find a device that is not in use. */ 617 /* find a device that is not in use. */
619 mutex_lock(&devpts_mutex); 618 tty_lock();
620 index = devpts_new_index(inode); 619 index = devpts_new_index(inode);
621 mutex_unlock(&devpts_mutex); 620 tty_unlock();
622 if (index < 0) { 621 if (index < 0) {
623 retval = index; 622 retval = index;
624 goto err_file; 623 goto err_file;
625 } 624 }
626 625
627 mutex_lock(&tty_mutex); 626 mutex_lock(&tty_mutex);
627 mutex_lock(&devpts_mutex);
628 tty = tty_init_dev(ptm_driver, index); 628 tty = tty_init_dev(ptm_driver, index);
629 mutex_unlock(&devpts_mutex);
630 tty_lock();
631 mutex_unlock(&tty_mutex);
629 632
630 if (IS_ERR(tty)) { 633 if (IS_ERR(tty)) {
631 retval = PTR_ERR(tty); 634 retval = PTR_ERR(tty);
632 goto out; 635 goto out;
633 } 636 }
634 637
635 /* The tty returned here is locked so we can safely
636 drop the mutex */
637 mutex_unlock(&tty_mutex);
638
639 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ 638 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
640 639
641 tty_add_file(tty, filp); 640 tty_add_file(tty, filp);
@@ -648,15 +647,15 @@ static int ptmx_open(struct inode *inode, struct file *filp)
648 if (retval) 647 if (retval)
649 goto err_release; 648 goto err_release;
650 649
651 tty_unlock(tty); 650 tty_unlock();
652 return 0; 651 return 0;
653err_release: 652err_release:
654 tty_unlock(tty); 653 tty_unlock();
655 tty_release(inode, filp); 654 tty_release(inode, filp);
656 return retval; 655 return retval;
657out: 656out:
658 mutex_unlock(&tty_mutex);
659 devpts_kill_index(inode, index); 657 devpts_kill_index(inode, index);
658 tty_unlock();
660err_file: 659err_file:
661 tty_free_file(filp); 660 tty_free_file(filp);
662 return retval; 661 return retval;