diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/tty_io.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index f24c26d2dba1..e45326856680 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1901,6 +1901,20 @@ static int init_dev(struct tty_driver *driver, int idx, | |||
1901 | /* check whether we're reopening an existing tty */ | 1901 | /* check whether we're reopening an existing tty */ |
1902 | if (driver->flags & TTY_DRIVER_DEVPTS_MEM) { | 1902 | if (driver->flags & TTY_DRIVER_DEVPTS_MEM) { |
1903 | tty = devpts_get_tty(idx); | 1903 | tty = devpts_get_tty(idx); |
1904 | /* | ||
1905 | * If we don't have a tty here on a slave open, it's because | ||
1906 | * the master already started the close process and there's | ||
1907 | * no relation between devpts file and tty anymore. | ||
1908 | */ | ||
1909 | if (!tty && driver->subtype == PTY_TYPE_SLAVE) { | ||
1910 | retval = -EIO; | ||
1911 | goto end_init; | ||
1912 | } | ||
1913 | /* | ||
1914 | * It's safe from now on because init_dev() is called with | ||
1915 | * tty_mutex held and release_dev() won't change tty->count | ||
1916 | * or tty->flags without having to grab tty_mutex | ||
1917 | */ | ||
1904 | if (tty && driver->subtype == PTY_TYPE_MASTER) | 1918 | if (tty && driver->subtype == PTY_TYPE_MASTER) |
1905 | tty = tty->link; | 1919 | tty = tty->link; |
1906 | } else { | 1920 | } else { |