diff options
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r-- | drivers/tty/pty.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index e809e9d4683c..e18604b3fc7d 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -670,12 +670,18 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
670 | 670 | ||
671 | nonseekable_open(inode, filp); | 671 | nonseekable_open(inode, filp); |
672 | 672 | ||
673 | retval = tty_alloc_file(filp); | ||
674 | if (retval) | ||
675 | return retval; | ||
676 | |||
673 | /* find a device that is not in use. */ | 677 | /* find a device that is not in use. */ |
674 | tty_lock(); | 678 | tty_lock(); |
675 | index = devpts_new_index(inode); | 679 | index = devpts_new_index(inode); |
676 | tty_unlock(); | 680 | tty_unlock(); |
677 | if (index < 0) | 681 | if (index < 0) { |
678 | return index; | 682 | retval = index; |
683 | goto err_file; | ||
684 | } | ||
679 | 685 | ||
680 | mutex_lock(&tty_mutex); | 686 | mutex_lock(&tty_mutex); |
681 | tty_lock(); | 687 | tty_lock(); |
@@ -689,27 +695,27 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
689 | 695 | ||
690 | set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ | 696 | set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ |
691 | 697 | ||
692 | retval = tty_add_file(tty, filp); | 698 | tty_add_file(tty, filp); |
693 | if (retval) | ||
694 | goto out; | ||
695 | 699 | ||
696 | retval = devpts_pty_new(inode, tty->link); | 700 | retval = devpts_pty_new(inode, tty->link); |
697 | if (retval) | 701 | if (retval) |
698 | goto out1; | 702 | goto err_release; |
699 | 703 | ||
700 | retval = ptm_driver->ops->open(tty, filp); | 704 | retval = ptm_driver->ops->open(tty, filp); |
701 | if (retval) | 705 | if (retval) |
702 | goto out2; | 706 | goto err_release; |
703 | out1: | 707 | |
704 | tty_unlock(); | 708 | tty_unlock(); |
705 | return retval; | 709 | return 0; |
706 | out2: | 710 | err_release: |
707 | tty_unlock(); | 711 | tty_unlock(); |
708 | tty_release(inode, filp); | 712 | tty_release(inode, filp); |
709 | return retval; | 713 | return retval; |
710 | out: | 714 | out: |
711 | devpts_kill_index(inode, index); | 715 | devpts_kill_index(inode, index); |
712 | tty_unlock(); | 716 | tty_unlock(); |
717 | err_file: | ||
718 | tty_free_file(filp); | ||
713 | return retval; | 719 | return retval; |
714 | } | 720 | } |
715 | 721 | ||