Skip to content

Commit 48628ec

Browse files
kot-begemot-ukgregkh
authored andcommitted
um: tty: Fix handling of close in tty lines
[ Upstream commit 9b1c0c0 ] Fix a logical error in tty reading. We get 0 and errno == EAGAIN on the first attempt to read from a closed file descriptor. Compared to that a true EAGAIN is EAGAIN and -1. If we check errno for EAGAIN first, before checking the return value we miss the fact that the descriptor is closed. This bug is as old as the driver. It was not showing up with the original POLL based IRQ controller, because it was producing multiple events. Switching to EPOLL unmasked it. Fixes: ff6a179 ("Epoll based IRQ controller") Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4553c8c commit 48628ec

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/um/drivers/chan_user.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ int generic_read(int fd, char *c_out, void *unused)
2626
n = read(fd, c_out, sizeof(*c_out));
2727
if (n > 0)
2828
return n;
29-
else if (errno == EAGAIN)
30-
return 0;
3129
else if (n == 0)
3230
return -EIO;
31+
else if (errno == EAGAIN)
32+
return 0;
3333
return -errno;
3434
}
3535

0 commit comments

Comments
 (0)