diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-01-21 10:08:15 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-01-21 10:34:33 -0800 |
commit | 1443b92a1ff3a0af5f0e5a177db2d843273a2ca1 (patch) | |
tree | a3edaafc60ec6f333126259dc23cf469591336ec | |
parent | bf6ee858fdff2a1800fd198bbe90034dcd60f3ef (diff) | |
download | linux-1443b92a1ff3a0af5f0e5a177db2d843273a2ca1.tar.gz linux-1443b92a1ff3a0af5f0e5a177db2d843273a2ca1.tar.bz2 linux-1443b92a1ff3a0af5f0e5a177db2d843273a2ca1.zip |
tty: fix up hung_up_tty_read() conversion
In commit "tty: implement read_iter", I left the read_iter conversion of
the hung up tty case alone, because I incorrectly thought it didn't
matter.
Jiri showed me the errors of my ways, and pointed out the problems with
that incomplete conversion. Fix it all up.
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/tty/tty_io.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 52489f8b7401..d7883da7ba3d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -431,8 +431,7 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line) EXPORT_SYMBOL_GPL(tty_find_polling_driver); #endif -static ssize_t hung_up_tty_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) +static ssize_t hung_up_tty_read(struct kiocb *iocb, struct iov_iter *to) { return 0; } @@ -504,7 +503,7 @@ static const struct file_operations console_fops = { static const struct file_operations hung_up_tty_fops = { .llseek = no_llseek, - .read = hung_up_tty_read, + .read_iter = hung_up_tty_read, .write_iter = hung_up_tty_write, .poll = hung_up_tty_poll, .unlocked_ioctl = hung_up_tty_ioctl, @@ -924,8 +923,10 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) /* We want to wait for the line discipline to sort out in this situation */ ld = tty_ldisc_ref_wait(tty); + if (!ld) + return hung_up_tty_read(iocb, to); i = -EIO; - if (ld && ld->ops->read) + if (ld->ops->read) i = iterate_tty_read(ld, tty, file, to); tty_ldisc_deref(ld); |