From: Minu Jin <s9430939@naver.com>
To: syzbot+b5d1f455d385b2c7da3c@syzkaller.appspotmail.com
Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] tty: n_gsm: fix memory leak in gsm_activate_mux
Date: Thu, 23 Apr 2026 02:37:01 +0900 [thread overview]
Message-ID: <aekHPX4zEYZoZFOp@JMW-Ubuntu> (raw)
I found a memory leak in gsm_activate_mux() from the syzbot dashboard.
I have analyzed the root cause and created a fix.
Please test the following patch.
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-next
---
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index c13e050de83b..de3d30eac86e 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2645,7 +2645,12 @@ static int gsm_dlci_config(struct gsm_dlci *dlci, struct gsm_dlci_config *dc, in
static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
{
- struct gsm_dlci *dlci = kzalloc_obj(struct gsm_dlci, GFP_ATOMIC);
+ struct gsm_dlci *dlci;
+
+ if (gsm->dlci[addr])
+ return gsm->dlci[addr];
+
+ dlci = kzalloc_obj(struct gsm_dlci, GFP_ATOMIC);
if (dlci == NULL)
return NULL;
spin_lock_init(&dlci->lock);
@@ -3196,8 +3201,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 */
next reply other threads:[~2026-04-22 17:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 17:37 Minu Jin [this message]
2026-04-22 18:04 ` [syzbot] [serial?] memory leak in gsm_activate_mux syzbot
-- strict thread matches above, loose matches on Subject: below --
2026-04-22 18:33 [PATCH] tty: n_gsm: fix " Minu Jin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aekHPX4zEYZoZFOp@JMW-Ubuntu \
--to=s9430939@naver.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=syzbot+b5d1f455d385b2c7da3c@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox