diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/pty.c | 6 | ||||
-rw-r--r-- | drivers/char/tty_ldisc.c | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 5acd29e..3910ce1 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -104,7 +104,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, struct tty_struct *to = tty->link; int c; - if (!to || tty->stopped) + if (!to || !to->ldisc || tty->stopped) return 0; c = to->receive_room; @@ -148,7 +148,7 @@ static int pty_chars_in_buffer(struct tty_struct *tty) int count; /* 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; /* 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) struct tty_struct *to = tty->link; unsigned long flags; - if (!to) + if (!to || !to->ldisc) return; if (to->ldisc->ops->flush_buffer) diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c index 39c8f86..94b3e06 100644 --- a/drivers/char/tty_ldisc.c +++ b/drivers/char/tty_ldisc.c @@ -148,8 +148,10 @@ static struct tty_ldisc *tty_ldisc_try_get(int disc) } } spin_unlock_irqrestore(&tty_ldisc_lock, flags); - if (err) + if (err) { + kfree(ld); return ERR_PTR(err); + } return ld; } @@ -262,7 +264,7 @@ const struct file_operations tty_ldiscs_proc_fops = { * @ld: line discipline * * Install an instance of a line discipline into a tty structure. The - * ldisc must have a reference count above zero to ensure it remains/ + * ldisc must have a reference count above zero to ensure it remains. * The tty instance refcount starts at zero. * * Locking: |