diff options
Diffstat (limited to 'drivers/tty/pty.c')
| -rw-r--r-- | drivers/tty/pty.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index d6579a9064c4..4399f1dbd131 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
| @@ -47,6 +47,7 @@ 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 ?? */ | ||
| 50 | if (!tty->link) | 51 | if (!tty->link) |
| 51 | return; | 52 | return; |
| 52 | tty->link->packet = 0; | 53 | tty->link->packet = 0; |
| @@ -62,9 +63,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp) | |||
| 62 | mutex_unlock(&devpts_mutex); | 63 | mutex_unlock(&devpts_mutex); |
| 63 | } | 64 | } |
| 64 | #endif | 65 | #endif |
| 65 | tty_unlock(); | 66 | tty_unlock(tty); |
| 66 | tty_vhangup(tty->link); | 67 | tty_vhangup(tty->link); |
| 67 | tty_lock(); | 68 | tty_lock(tty); |
| 68 | } | 69 | } |
| 69 | } | 70 | } |
| 70 | 71 | ||
| @@ -617,26 +618,27 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
| 617 | return retval; | 618 | return retval; |
| 618 | 619 | ||
| 619 | /* find a device that is not in use. */ | 620 | /* find a device that is not in use. */ |
| 620 | tty_lock(); | 621 | mutex_lock(&devpts_mutex); |
| 621 | index = devpts_new_index(inode); | 622 | index = devpts_new_index(inode); |
| 622 | tty_unlock(); | ||
| 623 | if (index < 0) { | 623 | if (index < 0) { |
| 624 | retval = index; | 624 | retval = index; |
| 625 | goto err_file; | 625 | goto err_file; |
| 626 | } | 626 | } |
| 627 | 627 | ||
| 628 | mutex_unlock(&devpts_mutex); | ||
| 629 | |||
| 628 | mutex_lock(&tty_mutex); | 630 | mutex_lock(&tty_mutex); |
| 629 | mutex_lock(&devpts_mutex); | ||
| 630 | tty = tty_init_dev(ptm_driver, index); | 631 | tty = tty_init_dev(ptm_driver, index); |
| 631 | mutex_unlock(&devpts_mutex); | ||
| 632 | tty_lock(); | ||
| 633 | mutex_unlock(&tty_mutex); | ||
| 634 | 632 | ||
| 635 | if (IS_ERR(tty)) { | 633 | if (IS_ERR(tty)) { |
| 636 | retval = PTR_ERR(tty); | 634 | retval = PTR_ERR(tty); |
| 637 | goto out; | 635 | goto out; |
| 638 | } | 636 | } |
| 639 | 637 | ||
| 638 | /* The tty returned here is locked so we can safely | ||
| 639 | drop the mutex */ | ||
| 640 | mutex_unlock(&tty_mutex); | ||
| 641 | |||
| 640 | set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ | 642 | set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ |
| 641 | 643 | ||
| 642 | tty_add_file(tty, filp); | 644 | tty_add_file(tty, filp); |
| @@ -649,16 +651,17 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
| 649 | if (retval) | 651 | if (retval) |
| 650 | goto err_release; | 652 | goto err_release; |
| 651 | 653 | ||
| 652 | tty_unlock(); | 654 | tty_unlock(tty); |
| 653 | return 0; | 655 | return 0; |
| 654 | err_release: | 656 | err_release: |
| 655 | tty_unlock(); | 657 | tty_unlock(tty); |
| 656 | tty_release(inode, filp); | 658 | tty_release(inode, filp); |
| 657 | return retval; | 659 | return retval; |
| 658 | out: | 660 | out: |
| 661 | mutex_unlock(&tty_mutex); | ||
| 659 | devpts_kill_index(inode, index); | 662 | devpts_kill_index(inode, index); |
| 660 | tty_unlock(); | ||
| 661 | err_file: | 663 | err_file: |
| 664 | mutex_unlock(&devpts_mutex); | ||
| 662 | tty_free_file(filp); | 665 | tty_free_file(filp); |
| 663 | return retval; | 666 | return retval; |
| 664 | } | 667 | } |
