Commit cbcb6d66 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

pty: Narrow the race on ldisc locking

The pty code has always been buggy on its ldisc handling. The recent
changes made the window for the race much bigger. Pending fixing it
properly which is not at all trivial, at least make the race small again so
we don't disrupt other dev work.
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b231125a
...@@ -104,7 +104,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, ...@@ -104,7 +104,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf,
struct tty_struct *to = tty->link; struct tty_struct *to = tty->link;
int c; int c;
if (!to || tty->stopped) if (!to || !to->ldisc || tty->stopped)
return 0; return 0;
c = to->receive_room; c = to->receive_room;
...@@ -148,7 +148,7 @@ static int pty_chars_in_buffer(struct tty_struct *tty) ...@@ -148,7 +148,7 @@ static int pty_chars_in_buffer(struct tty_struct *tty)
int count; int count;
/* We should get the line discipline lock for "tty->link" */ /* We should get the line discipline lock for "tty->link" */
if (!to || !to->ldisc->ops->chars_in_buffer) if (!to || !to->ldisc || !to->ldisc->ops->chars_in_buffer)
return 0; return 0;
/* The ldisc must report 0 if no characters available to be read */ /* The ldisc must report 0 if no characters available to be read */
...@@ -183,7 +183,7 @@ static void pty_flush_buffer(struct tty_struct *tty) ...@@ -183,7 +183,7 @@ static void pty_flush_buffer(struct tty_struct *tty)
struct tty_struct *to = tty->link; struct tty_struct *to = tty->link;
unsigned long flags; unsigned long flags;
if (!to) if (!to || !to->ldisc)
return; return;
if (to->ldisc->ops->flush_buffer) if (to->ldisc->ops->flush_buffer)
......
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