Skip to content

Commit edd5f60

Browse files
dstarke-siemensgregkh
authored andcommitted
tty: n_gsm: fix mux activation issues in gsm_config()
The current implementation activates the mux if it was restarted and opens the control channel if the mux was previously closed and we are now acting as initiator instead of responder, which is the default setting. This has two issues. 1) No mux is activated if we keep all default values and only switch to initiator. The control channel is not allocated but will be opened next which results in a NULL pointer dereference. 2) Switching the configuration after it was once configured while keeping the initiator value the same will not reopen the control channel if it was closed due to parameter incompatibilities. The mux remains dead. Fix 1) by always activating the mux if it is dead after configuration. Fix 2) by always opening the control channel after mux activation. Fixes: e1eaea4 ("tty: n_gsm line discipline") Cc: [email protected] Signed-off-by: Daniel Starke <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fd442e5 commit edd5f60

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/tty/n_gsm.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,7 @@ static void gsm_copy_config_values(struct gsm_mux *gsm,
23522352

23532353
static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
23542354
{
2355+
int ret = 0;
23552356
int need_close = 0;
23562357
int need_restart = 0;
23572358

@@ -2419,10 +2420,13 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
24192420
* FIXME: We need to separate activation/deactivation from adding
24202421
* and removing from the mux array
24212422
*/
2422-
if (need_restart)
2423-
gsm_activate_mux(gsm);
2424-
if (gsm->initiator && need_close)
2425-
gsm_dlci_begin_open(gsm->dlci[0]);
2423+
if (gsm->dead) {
2424+
ret = gsm_activate_mux(gsm);
2425+
if (ret)
2426+
return ret;
2427+
if (gsm->initiator)
2428+
gsm_dlci_begin_open(gsm->dlci[0]);
2429+
}
24262430
return 0;
24272431
}
24282432

0 commit comments

Comments
 (0)