Skip to content

Commit

Permalink
um: tty: Fix handling of close in tty lines
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anton Ivanov authored and richardweinberger committed Dec 13, 2020
1 parent e3a01cb commit 9b1c0c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/um/drivers/chan_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9b1c0c0

Please sign in to comment.