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>
This commit is contained in:
Linus Torvalds 2021-01-21 10:04:27 -08:00 committed by Greg Kroah-Hartman
parent 3cfade53c7
commit c7135bbe5a
1 changed files with 5 additions and 4 deletions

View File

@ -437,8 +437,7 @@ static ssize_t hung_up_tty_read(struct file *file, char __user *buf,
return 0; return 0;
} }
static ssize_t hung_up_tty_write(struct file *file, const char __user *buf, static ssize_t hung_up_tty_write(struct kiocb *iocb, struct iov_iter *from)
size_t count, loff_t *ppos)
{ {
return -EIO; return -EIO;
} }
@ -506,7 +505,7 @@ static const struct file_operations console_fops = {
static const struct file_operations hung_up_tty_fops = { static const struct file_operations hung_up_tty_fops = {
.llseek = no_llseek, .llseek = no_llseek,
.read = hung_up_tty_read, .read = hung_up_tty_read,
.write = hung_up_tty_write, .write_iter = hung_up_tty_write,
.poll = hung_up_tty_poll, .poll = hung_up_tty_poll,
.unlocked_ioctl = hung_up_tty_ioctl, .unlocked_ioctl = hung_up_tty_ioctl,
.compat_ioctl = hung_up_tty_compat_ioctl, .compat_ioctl = hung_up_tty_compat_ioctl,
@ -1119,7 +1118,9 @@ static ssize_t tty_write(struct kiocb *iocb, struct iov_iter *from)
if (tty->ops->write_room == NULL) if (tty->ops->write_room == NULL)
tty_err(tty, "missing write_room method\n"); tty_err(tty, "missing write_room method\n");
ld = tty_ldisc_ref_wait(tty); ld = tty_ldisc_ref_wait(tty);
if (!ld || !ld->ops->write) if (!ld)
return hung_up_tty_write(iocb, from);
if (!ld->ops->write)
ret = -EIO; ret = -EIO;
else else
ret = do_tty_write(ld->ops->write, tty, file, from); ret = do_tty_write(ld->ops->write, tty, file, from);