Prevent an O_NDELAY writer from blocking when a tty write is blocked by the tty atomic writer mutex

Without this a tty write could block if a previous blocking tty write was
in progress on the same tty and blocked by a line discipline or hardware
event.  Originally found and reported by Dave Johnson.

Signed-off-by: Alan Cox <alan@redhat.com>
Acked-by: Dave Johnson <djohnson+linux-kernel@sw.starentnetworks.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox
2007-07-15 23:39:43 -07:00
committed by Linus Torvalds
parent c9c64155f5
commit 9c1729db3e
5 changed files with 43 additions and 19 deletions

View File

@ -667,7 +667,7 @@ static int send_prio_char(struct tty_struct *tty, char ch)
return 0;
}
if (mutex_lock_interruptible(&tty->atomic_write_lock))
if (tty_write_lock(tty, 0) < 0)
return -ERESTARTSYS;
if (was_stopped)
@ -675,7 +675,7 @@ static int send_prio_char(struct tty_struct *tty, char ch)
tty->driver->write(tty, &ch, 1);
if (was_stopped)
stop_tty(tty);
mutex_unlock(&tty->atomic_write_lock);
tty_write_unlock(tty);
return 0;
}