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_write() conversion

In commit "tty: implement write_iter", I left the write_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
c7135bbe 3cfade53

+5 -4
+5 -4
drivers/tty/tty_io.c
··· 437 437 return 0; 438 438 } 439 439 440 - static ssize_t hung_up_tty_write(struct file *file, const char __user *buf, 441 - size_t count, loff_t *ppos) 440 + static ssize_t hung_up_tty_write(struct kiocb *iocb, struct iov_iter *from) 442 441 { 443 442 return -EIO; 444 443 } ··· 505 506 static const struct file_operations hung_up_tty_fops = { 506 507 .llseek = no_llseek, 507 508 .read = hung_up_tty_read, 508 - .write = hung_up_tty_write, 509 + .write_iter = hung_up_tty_write, 509 510 .poll = hung_up_tty_poll, 510 511 .unlocked_ioctl = hung_up_tty_ioctl, 511 512 .compat_ioctl = hung_up_tty_compat_ioctl, ··· 1118 1119 if (tty->ops->write_room == NULL) 1119 1120 tty_err(tty, "missing write_room method\n"); 1120 1121 ld = tty_ldisc_ref_wait(tty); 1121 - if (!ld || !ld->ops->write) 1122 + if (!ld) 1123 + return hung_up_tty_write(iocb, from); 1124 + if (!ld->ops->write) 1122 1125 ret = -EIO; 1123 1126 else 1124 1127 ret = do_tty_write(ld->ops->write, tty, file, from);