aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/pty.c8
-rw-r--r--drivers/tty/tty_io.c12
-rw-r--r--include/linux/tty.h3
3 files changed, 6 insertions, 17 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d8653ab6f498..03147fa31d47 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -515,10 +515,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
515static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver, 515static struct tty_struct *ptm_unix98_lookup(struct tty_driver *driver,
516 struct inode *ptm_inode, int idx) 516 struct inode *ptm_inode, int idx)
517{ 517{
518 struct tty_struct *tty = devpts_get_tty(ptm_inode, idx); 518 /* Master must be open via /dev/ptmx */
519 if (tty) 519 return ERR_PTR(-EIO);
520 tty = tty->link;
521 return tty;
522} 520}
523 521
524/** 522/**
@@ -677,7 +675,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
677 675
678 mutex_lock(&tty_mutex); 676 mutex_lock(&tty_mutex);
679 tty_lock(); 677 tty_lock();
680 tty = tty_init_dev(ptm_driver, index, 1); 678 tty = tty_init_dev(ptm_driver, index);
681 mutex_unlock(&tty_mutex); 679 mutex_unlock(&tty_mutex);
682 680
683 if (IS_ERR(tty)) { 681 if (IS_ERR(tty)) {
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index e41b9bbc107d..fbcc14063804 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1365,7 +1365,6 @@ static int tty_reopen(struct tty_struct *tty)
1365 * @driver: tty driver we are opening a device on 1365 * @driver: tty driver we are opening a device on
1366 * @idx: device index 1366 * @idx: device index
1367 * @ret_tty: returned tty structure 1367 * @ret_tty: returned tty structure
1368 * @first_ok: ok to open a new device (used by ptmx)
1369 * 1368 *
1370 * Prepare a tty device. This may not be a "new" clean device but 1369 * Prepare a tty device. This may not be a "new" clean device but
1371 * could also be an active device. The pty drivers require special 1370 * could also be an active device. The pty drivers require special
@@ -1385,18 +1384,11 @@ static int tty_reopen(struct tty_struct *tty)
1385 * relaxed for the (most common) case of reopening a tty. 1384 * relaxed for the (most common) case of reopening a tty.
1386 */ 1385 */
1387 1386
1388struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 1387struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
1389 int first_ok)
1390{ 1388{
1391 struct tty_struct *tty; 1389 struct tty_struct *tty;
1392 int retval; 1390 int retval;
1393 1391
1394 /* Check if pty master is being opened multiple times */
1395 if (driver->subtype == PTY_TYPE_MASTER &&
1396 (driver->flags & TTY_DRIVER_DEVPTS_MEM) && !first_ok) {
1397 return ERR_PTR(-EIO);
1398 }
1399
1400 /* 1392 /*
1401 * First time open is complex, especially for PTY devices. 1393 * First time open is complex, especially for PTY devices.
1402 * This code guarantees that either everything succeeds and the 1394 * This code guarantees that either everything succeeds and the
@@ -1950,7 +1942,7 @@ retry_open:
1950 if (retval) 1942 if (retval)
1951 tty = ERR_PTR(retval); 1943 tty = ERR_PTR(retval);
1952 } else 1944 } else
1953 tty = tty_init_dev(driver, index, 0); 1945 tty = tty_init_dev(driver, index);
1954 1946
1955 mutex_unlock(&tty_mutex); 1947 mutex_unlock(&tty_mutex);
1956 if (driver) 1948 if (driver)
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 5dbb3cb05a82..d3ebd765b548 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -480,8 +480,7 @@ extern void free_tty_struct(struct tty_struct *tty);
480extern void initialize_tty_struct(struct tty_struct *tty, 480extern void initialize_tty_struct(struct tty_struct *tty,
481 struct tty_driver *driver, int idx); 481 struct tty_driver *driver, int idx);
482extern void deinitialize_tty_struct(struct tty_struct *tty); 482extern void deinitialize_tty_struct(struct tty_struct *tty);
483extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, 483extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx);
484 int first_ok);
485extern int tty_release(struct inode *inode, struct file *filp); 484extern int tty_release(struct inode *inode, struct file *filp);
486extern int tty_init_termios(struct tty_struct *tty); 485extern int tty_init_termios(struct tty_struct *tty);
487 486