um: tty: Fix handling of close in tty lines
authorAnton Ivanov <anton.ivanov@cambridgegreys.com>
Mon, 7 Dec 2020 17:19:39 +0000 (17:19 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:53:52 +0000 (11:53 +0100)
commit48628ec96d2ec572b0a44a8d078e7d80f2950ceb
treebd7633fd14806c24ae0e21f902555fa0f5e812c0
parent4553c8cecbefdfe0133ed21c27e0e1c16b70f46d
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>
arch/um/drivers/chan_user.c