Skip to content

Commit

Permalink
tty: n_gsm: fix mux cleanup after unregister tty device
Browse files Browse the repository at this point in the history
commit 284260f upstream.

Internally, we manage the alive state of the mux channels and mux itself
with the field member 'dead'. This makes it possible to notify the user
if the accessed underlying link is already gone. On the other hand,
however, removing the virtual ttys before terminating the channels may
result in peer messages being received without any internal target. Move
the mux cleanup procedure from gsmld_detach_gsm() to gsmld_close() to fix
this by keeping the virtual ttys open until the mux has been cleaned up.

Fixes: e1eaea4 ("tty: n_gsm line discipline")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
Link: https://lore.kernel.org/r/20220414094225.4527-4-daniel.starke@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
dstarke-siemens authored and gregkh committed May 9, 2022
1 parent 68cacd9 commit 472d5c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/tty/n_gsm.c
Expand Up @@ -2479,7 +2479,6 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
for (i = 1; i < NUM_DLCI; i++)
tty_unregister_device(gsm_tty_driver, base + i);
}
gsm_cleanup_mux(gsm, false);
tty_kref_put(gsm->tty);
gsm->tty = NULL;
}
Expand Down Expand Up @@ -2544,6 +2543,12 @@ static void gsmld_close(struct tty_struct *tty)
{
struct gsm_mux *gsm = tty->disc_data;

/* The ldisc locks and closes the port before calling our close. This
* means we have no way to do a proper disconnect. We will not bother
* to do one.
*/
gsm_cleanup_mux(gsm, false);

gsmld_detach_gsm(tty, gsm);

gsmld_flush_buffer(tty);
Expand Down

0 comments on commit 472d5c3

Please sign in to comment.