linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Edward AD <twuufnxlz@gmail.com>
To: gregkh@linuxfoundation.org
Cc: eadavis@sina.com, jirislaby@kernel.org,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	syzbot+b5d1f455d385b2c7da3c@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: [PATCH] tty: fix memory leak in gsm_activate_mux
Date: Tue, 19 Sep 2023 16:02:08 +0800	[thread overview]
Message-ID: <20230919080207.3654671-2-twuufnxlz@gmail.com> (raw)
In-Reply-To: <2023091954-algebra-hastiness-3bb8@gregkh>

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@syzkaller.appspotmail.com
Signed-off-by: Edward AD <twuufnxlz@gmail.com>
---
 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


  reply	other threads:[~2023-09-19  8:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15  6:29 [syzbot] [serial?] memory leak in gsm_activate_mux syzbot
     [not found] ` <20230915112324.941574-1-eadavis@sina.com>
2023-09-18  8:06   ` [PATCH] tty: fix " Greg KH
     [not found]     ` <20230918084526.2824669-1-eadavis@sina.com>
2023-09-18  9:13       ` Greg KH
     [not found]         ` <20230918104836.2933871-1-eadavis@sina.com>
2023-09-18 12:02           ` Greg KH
     [not found]             ` <20230919034524.3425915-2-eadavis@sina.com>
2023-09-19  7:35               ` Greg KH
2023-09-19  8:02                 ` Edward AD [this message]
2023-09-19  8:29                   ` Greg KH
2023-09-19  9:22                     ` Edward AD
2023-09-19  9:31                       ` Greg KH
2023-09-19  9:55                         ` Edward AD
2023-09-20  6:38                         ` Edward AD

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=20230919080207.3654671-2-twuufnxlz@gmail.com \
    --to=twuufnxlz@gmail.com \
    --cc=eadavis@sina.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=syzbot+b5d1f455d385b2c7da3c@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).