Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/CAHk-=wh+-rGsa=xruEWdg_fJViFG8rN9bpLrfLz=_yBYh2tBhA@mail.gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Linus Torvalds and committed by
Greg Kroah-Hartman
ddc5fda7 c7135bbe

+5 -4
+5 -4
drivers/tty/tty_io.c
··· 431 431 EXPORT_SYMBOL_GPL(tty_find_polling_driver); 432 432 #endif 433 433 434 - static ssize_t hung_up_tty_read(struct file *file, char __user *buf, 435 - size_t count, loff_t *ppos) 434 + static ssize_t hung_up_tty_read(struct kiocb *iocb, struct iov_iter *to) 436 435 { 437 436 return 0; 438 437 } ··· 503 504 504 505 static const struct file_operations hung_up_tty_fops = { 505 506 .llseek = no_llseek, 506 - .read = hung_up_tty_read, 507 + .read_iter = hung_up_tty_read, 507 508 .write_iter = hung_up_tty_write, 508 509 .poll = hung_up_tty_poll, 509 510 .unlocked_ioctl = hung_up_tty_ioctl, ··· 939 940 /* We want to wait for the line discipline to sort out in this 940 941 situation */ 941 942 ld = tty_ldisc_ref_wait(tty); 943 + if (!ld) 944 + return hung_up_tty_read(iocb, to); 942 945 i = -EIO; 943 - if (ld && ld->ops->read) 946 + if (ld->ops->read) 944 947 i = iterate_tty_read(ld, tty, file, to); 945 948 tty_ldisc_deref(ld); 946 949