Skip to content

Commit 1774985

Browse files
torvaldsgregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Reviewed-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/CAHk-=wh+-rGsa=xruEWdg_fJViFG8rN9bpLrfLz=_yBYh2tBhA@mail.gmail.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 494e63e commit 1774985

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/tty/tty_io.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,7 @@ static ssize_t hung_up_tty_read(struct file *file, char __user *buf,
437437
return 0;
438438
}
439439

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)
442441
{
443442
return -EIO;
444443
}
@@ -504,7 +503,7 @@ static const struct file_operations console_fops = {
504503
static const struct file_operations hung_up_tty_fops = {
505504
.llseek = no_llseek,
506505
.read = hung_up_tty_read,
507-
.write = hung_up_tty_write,
506+
.write_iter = hung_up_tty_write,
508507
.poll = hung_up_tty_poll,
509508
.unlocked_ioctl = hung_up_tty_ioctl,
510509
.compat_ioctl = hung_up_tty_compat_ioctl,
@@ -1044,7 +1043,9 @@ static ssize_t tty_write(struct kiocb *iocb, struct iov_iter *from)
10441043
if (tty->ops->write_room == NULL)
10451044
tty_err(tty, "missing write_room method\n");
10461045
ld = tty_ldisc_ref_wait(tty);
1047-
if (!ld || !ld->ops->write)
1046+
if (!ld)
1047+
return hung_up_tty_write(iocb, from);
1048+
if (!ld->ops->write)
10481049
ret = -EIO;
10491050
else
10501051
ret = do_tty_write(ld->ops->write, tty, file, from);

0 commit comments

Comments
 (0)