From: Greg Kroah-Hartman Date: Sun, 20 Jan 2019 09:46:58 +0000 (+0100) Subject: tty: Handle problem if line discipline does not have receive_buf X-Git-Tag: v4.19.19~58 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=80250b48803ab0aa3eb8e0d798a4742b26ef84d9;p=users%2Fdwmw2%2Flinux.git tty: Handle problem if line discipline does not have receive_buf commit 27cfb3a53be46a54ec5e0bd04e51995b74c90343 upstream. Some tty line disciplines do not have a receive buf callback, so properly check for that before calling it. If they do not have this callback, just eat the character quietly, as we can't fail this call. Reported-by: Jann Horn Cc: stable Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 052ec16a4e84e..e7d192ebecd7d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2188,7 +2188,8 @@ static int tiocsti(struct tty_struct *tty, char __user *p) ld = tty_ldisc_ref_wait(tty); if (!ld) return -EIO; - ld->ops->receive_buf(tty, &ch, &mbz, 1); + if (ld->ops->receive_buf) + ld->ops->receive_buf(tty, &ch, &mbz, 1); tty_ldisc_deref(ld); return 0; }