aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/pty.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-26 09:11:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-26 09:11:09 -0400
commitefb8d21b2c6db3497655cc6a033ae8a9883e4063 (patch)
treea14a0dbb9fec3a6db5e542ba7ed4a49681706420 /drivers/tty/pty.c
parent3cb603284b3d256ae9ae9e65887cee8416bfef15 (diff)
parentd208a3bf77f902283894f546b6b5383202cf7882 (diff)
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (79 commits) TTY: serial_core: Fix crash if DCD drop during suspend tty/serial: atmel_serial: bootconsole removed from auto-enumerates Revert "TTY: call tty_driver_lookup_tty unconditionally" tty/serial: atmel_serial: add device tree support tty/serial: atmel_serial: auto-enumerate ports tty/serial: atmel_serial: whitespace and braces modifications tty/serial: atmel_serial: change platform_data variable name tty/serial: RS485 bindings for device tree TTY: call tty_driver_lookup_tty unconditionally TTY: pty, release tty in all ptmx_open fail paths TTY: make tty_add_file non-failing TTY: drop driver reference in tty_open fail path 8250_pci: Fix kernel panic when pch_uart is disabled h8300: drivers/serial/Kconfig was moved parport_pc: release IO region properly if unsupported ITE887x card is found tty: Support compat_ioctl get/set termios_locked hvc_console: display printk messages on console. TTY: snyclinkmp: forever loop in tx_load_dma_buffer() tty/n_gsm: avoid fifo overflow in gsm_dlci_data_output tty/n_gsm: fix a bug in gsm_dlci_data_output (adaption = 2 case) ... Fix up Conflicts in: - drivers/tty/serial/8250_pci.c Trivial conflict with removed duplicate device ID - drivers/tty/serial/atmel_serial.c Annoying silly conflict between "specify the port num via platform_data" and other changes to atmel_console_init
Diffstat (limited to 'drivers/tty/pty.c')
-rw-r--r--drivers/tty/pty.c26
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;
703out1: 707
704 tty_unlock(); 708 tty_unlock();
705 return retval; 709 return 0;
706out2: 710err_release:
707 tty_unlock(); 711 tty_unlock();
708 tty_release(inode, filp); 712 tty_release(inode, filp);
709 return retval; 713 return retval;
710out: 714out:
711 devpts_kill_index(inode, index); 715 devpts_kill_index(inode, index);
712 tty_unlock(); 716 tty_unlock();
717err_file:
718 tty_free_file(filp);
713 return retval; 719 return retval;
714} 720}
715 721