tty: n_gsm: fix mux cleanup after unregister tty device
authorDaniel Starke <daniel.starke@siemens.com>
Thu, 14 Apr 2022 09:42:09 +0000 (02:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 May 2022 07:14:42 +0000 (09:14 +0200)
commit4e1beef38c351a85403b835e128329cf9edbe0b0
tree598b30549fb5a8d970f789a0d5536342a70d50e0
parent8b19dfb3e8174824315325691d869be90a3a96c2
tty: n_gsm: fix mux cleanup after unregister tty device

commit 284260f278b706364fb4c88a7b56ba5298d5973c 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: e1eaea46bb40 ("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>
drivers/tty/n_gsm.c