Commit 9c5a7d9d authored by Linus Torvalds's avatar Linus Torvalds

Fix possible pty line discipline race.

This ain't pretty. Real fix under discussion.
parent 06c8faf3
......@@ -149,13 +149,15 @@ static int pty_write_room(struct tty_struct *tty)
static int pty_chars_in_buffer(struct tty_struct *tty)
{
struct tty_struct *to = tty->link;
ssize_t (*chars_in_buffer)(struct tty_struct *);
int count;
if (!to || !to->ldisc.chars_in_buffer)
/* We should get the line discipline lock for "tty->link" */
if (!to || !(chars_in_buffer = to->ldisc.chars_in_buffer))
return 0;
/* The ldisc must report 0 if no characters available to be read */
count = to->ldisc.chars_in_buffer(to);
count = chars_in_buffer(to);
if (tty->driver->subtype == PTY_TYPE_SLAVE) return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment