Skip to content

Commit a2ab75b

Browse files
dstarke-siemensgregkh
authored andcommitted
tty: n_gsm: fix deadlock in gsmtty_open()
In the current implementation the user may open a virtual tty which then could fail to establish the underlying DLCI. The function gsmtty_open() gets stuck in tty_port_block_til_ready() while waiting for a carrier rise. This happens if the remote side fails to acknowledge the link establishment request in time or completely. At some point gsm_dlci_close() is called to abort the link establishment attempt. The function tries to inform the associated virtual tty by performing a hangup. But the blocking loop within tty_port_block_til_ready() is not informed about this event. The patch proposed here fixes this by resetting the initialization state of the virtual tty to ensure the loop exits and triggering it to make tty_port_block_til_ready() return. 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/20220218073123.2121-7-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 687f9ad commit a2ab75b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/tty/n_gsm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,9 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)
14571457
if (dlci->addr != 0) {
14581458
tty_port_tty_hangup(&dlci->port, false);
14591459
kfifo_reset(&dlci->fifo);
1460+
/* Ensure that gsmtty_open() can return. */
1461+
tty_port_set_initialized(&dlci->port, 0);
1462+
wake_up_interruptible(&dlci->port.open_wait);
14601463
} else
14611464
dlci->gsm->dead = true;
14621465
/* Unregister gsmtty driver,report gsmtty dev remove uevent for user */

0 commit comments

Comments
 (0)