aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tty_io.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index e881e9ed08de..36098ee8fe65 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1376,19 +1376,6 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
1376 struct tty_struct *tty; 1376 struct tty_struct *tty;
1377 int retval; 1377 int retval;
1378 1378
1379 /* check whether we're reopening an existing tty */
1380 tty = tty_driver_lookup_tty(driver, idx);
1381
1382 if (IS_ERR(tty))
1383 return tty;
1384
1385 if (tty) {
1386 retval = tty_reopen(tty);
1387 if (retval)
1388 return ERR_PTR(retval);
1389 return tty;
1390 }
1391
1392 /* Check if pty master is being opened multiple times */ 1379 /* Check if pty master is being opened multiple times */
1393 if (driver->subtype == PTY_TYPE_MASTER && 1380 if (driver->subtype == PTY_TYPE_MASTER &&
1394 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) 1381 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok)
@@ -1790,7 +1777,7 @@ void tty_release_dev(struct file *filp)
1790 1777
1791static int __tty_open(struct inode *inode, struct file *filp) 1778static int __tty_open(struct inode *inode, struct file *filp)
1792{ 1779{
1793 struct tty_struct *tty; 1780 struct tty_struct *tty = NULL;
1794 int noctty, retval; 1781 int noctty, retval;
1795 struct tty_driver *driver; 1782 struct tty_driver *driver;
1796 int index; 1783 int index;
@@ -1847,7 +1834,21 @@ retry_open:
1847 return -ENODEV; 1834 return -ENODEV;
1848 } 1835 }
1849got_driver: 1836got_driver:
1850 tty = tty_init_dev(driver, index, 0); 1837 if (!tty) {
1838 /* check whether we're reopening an existing tty */
1839 tty = tty_driver_lookup_tty(driver, index);
1840
1841 if (IS_ERR(tty))
1842 return PTR_ERR(tty);
1843 }
1844
1845 if (tty) {
1846 retval = tty_reopen(tty);
1847 if (retval)
1848 tty = ERR_PTR(retval);
1849 } else
1850 tty = tty_init_dev(driver, index, 0);
1851
1851 mutex_unlock(&tty_mutex); 1852 mutex_unlock(&tty_mutex);
1852 tty_driver_kref_put(driver); 1853 tty_driver_kref_put(driver);
1853 if (IS_ERR(tty)) 1854 if (IS_ERR(tty))