diff options
Diffstat (limited to 'drivers/tty/tty_io.c')
| -rw-r--r-- | drivers/tty/tty_io.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index bfe9ad85b362..21ffcce16927 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++; |
| @@ -2183,7 +2189,8 @@ static int tiocsti(struct tty_struct *tty, char __user *p) | |||
| 2183 | ld = tty_ldisc_ref_wait(tty); | 2189 | ld = tty_ldisc_ref_wait(tty); |
| 2184 | if (!ld) | 2190 | if (!ld) |
| 2185 | return -EIO; | 2191 | return -EIO; |
| 2186 | ld->ops->receive_buf(tty, &ch, &mbz, 1); | 2192 | if (ld->ops->receive_buf) |
| 2193 | ld->ops->receive_buf(tty, &ch, &mbz, 1); | ||
| 2187 | tty_ldisc_deref(ld); | 2194 | tty_ldisc_deref(ld); |
| 2188 | return 0; | 2195 | return 0; |
| 2189 | } | 2196 | } |
