diff options
| -rw-r--r-- | drivers/tty/tty_io.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index bfe9ad85b362..23c6fd238422 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
| @@ -1256,7 +1256,8 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct * | |||
| 1256 | static int tty_reopen(struct tty_struct *tty) | 1256 | static int tty_reopen(struct tty_struct *tty) |
| 1257 | { | 1257 | { |
| 1258 | struct tty_driver *driver = tty->driver; | 1258 | struct tty_driver *driver = tty->driver; |
| 1259 | int retval; | 1259 | struct tty_ldisc *ld; |
| 1260 | int retval = 0; | ||
| 1260 | 1261 | ||
| 1261 | if (driver->type == TTY_DRIVER_TYPE_PTY && | 1262 | if (driver->type == TTY_DRIVER_TYPE_PTY && |
| 1262 | driver->subtype == PTY_TYPE_MASTER) | 1263 | driver->subtype == PTY_TYPE_MASTER) |
| @@ -1268,13 +1269,18 @@ static int tty_reopen(struct tty_struct *tty) | |||
| 1268 | if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) | 1269 | if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) |
| 1269 | return -EBUSY; | 1270 | return -EBUSY; |
| 1270 | 1271 | ||
| 1271 | retval = tty_ldisc_lock(tty, 5 * HZ); | 1272 | ld = tty_ldisc_ref_wait(tty); |
| 1272 | if (retval) | 1273 | if (ld) { |
| 1273 | return retval; | 1274 | tty_ldisc_deref(ld); |
| 1275 | } else { | ||
| 1276 | retval = tty_ldisc_lock(tty, 5 * HZ); | ||
| 1277 | if (retval) | ||
| 1278 | return retval; | ||
| 1274 | 1279 | ||
| 1275 | if (!tty->ldisc) | 1280 | if (!tty->ldisc) |
| 1276 | retval = tty_ldisc_reinit(tty, tty->termios.c_line); | 1281 | retval = tty_ldisc_reinit(tty, tty->termios.c_line); |
| 1277 | tty_ldisc_unlock(tty); | 1282 | tty_ldisc_unlock(tty); |
| 1283 | } | ||
| 1278 | 1284 | ||
| 1279 | if (retval == 0) | 1285 | if (retval == 0) |
| 1280 | tty->count++; | 1286 | tty->count++; |
