diff options
author | Anton Ivanov <anton.ivanov@cambridgegreys.com> | 2020-12-07 17:19:39 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-12-30 11:51:26 +0100 |
commit | 1bbd5678c0b40cbd28ddea105af8a04401067fb0 (patch) | |
tree | 76c02bb248256606f34e4c5ea34f2f0269d048bd /arch/um | |
parent | 1355bbe3a7172ead5eb974bf28da653e084e5762 (diff) | |
download | linux-stable-1bbd5678c0b40cbd28ddea105af8a04401067fb0.tar.gz linux-stable-1bbd5678c0b40cbd28ddea105af8a04401067fb0.tar.bz2 linux-stable-1bbd5678c0b40cbd28ddea105af8a04401067fb0.zip |
um: tty: Fix handling of close in tty lines
[ Upstream commit 9b1c0c0e25dcccafd30e7d4c150c249cc65550eb ]
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: ff6a17989c08 ("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>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/drivers/chan_user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 4d80526a4236..d8845d4aac6a 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c @@ -26,10 +26,10 @@ int generic_read(int fd, char *c_out, void *unused) n = read(fd, c_out, sizeof(*c_out)); if (n > 0) return n; - else if (errno == EAGAIN) - return 0; else if (n == 0) return -EIO; + else if (errno == EAGAIN) + return 0; return -errno; } |