When the call to gsm_register_devices() fails, we need to reclaim the memory requested in gsm_dlci_alloc(). Fixes: 01aecd917114 ("tty: n_gsm: fix tty registration before control channel open") Reported-and-tested-by: syzbot+b5d1f455d385b2c7da3c@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Edward AD <twuufnxlz@xxxxxxxxx> --- drivers/tty/n_gsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index b3550ff9c494..df9bb87652b0 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3136,8 +3136,10 @@ static int gsm_activate_mux(struct gsm_mux *gsm) gsm->receive = gsm1_receive; ret = gsm_register_devices(gsm_tty_driver, gsm->num); - if (ret) + if (ret) { + gsm_dlci_free(&dlci->port); return ret; + } gsm->has_devices = true; gsm->dead = false; /* Tty opens are now permissible */ -- 2.25.1