diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 2e50f4d..ace0c19 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -1813,13 +1813,13 @@ do_it_again: if (tty->icanon) { /* N.B. avoid overrun if nr == 0 */ + spin_lock_irqsave(&tty->read_lock, flags); while (nr && tty->read_cnt) { int eol; eol = test_and_clear_bit(tty->read_tail, tty->read_flags); c = tty->read_buf[tty->read_tail]; - spin_lock_irqsave(&tty->read_lock, flags); tty->read_tail = ((tty->read_tail+1) & (N_TTY_BUF_SIZE-1)); tty->read_cnt--; @@ -1831,7 +1831,6 @@ do_it_again: if (--tty->canon_data < 0) tty->canon_data = 0; } - spin_unlock_irqrestore(&tty->read_lock, flags); if (!eol || (c != __DISABLED_CHAR)) { if (tty_put_user(tty, c, b++)) { @@ -1846,6 +1845,7 @@ do_it_again: break; } } + spin_unlock_irqrestore(&tty->read_lock, flags); if (retval) break; } else {