Skip to content

Commit

Permalink
tty: n_gsm: fix missing corner cases in gsmld_poll()
Browse files Browse the repository at this point in the history
gsmld_poll() currently fails to handle the following corner cases correctly:
- remote party closed the associated tty

Add the missing checks and map those to EPOLLHUP.
Reorder the checks to group them by their reaction.

Fixes: e1eaea4 ("tty: n_gsm line discipline")
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
Link: https://lore.kernel.org/r/20220707113223.3685-4-daniel.starke@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Daniel Starke authored and Greg Kroah-Hartman committed Jul 8, 2022
1 parent 59ff068 commit 7e5b432
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/tty/n_gsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3053,12 +3053,15 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file,

poll_wait(file, &tty->read_wait, wait);
poll_wait(file, &tty->write_wait, wait);

if (gsm->dead)
mask |= EPOLLHUP;
if (tty_hung_up_p(file))
mask |= EPOLLHUP;
if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
mask |= EPOLLHUP;
if (!tty_is_writelocked(tty) && tty_write_room(tty) > 0)
mask |= EPOLLOUT | EPOLLWRNORM;
if (gsm->dead)
mask |= EPOLLHUP;
return mask;
}

Expand Down

0 comments on commit 7e5b432

Please sign in to comment.