From: Dan Carpenter <dan.carpenter@oracle.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sun Peng <sun_peng@topsec.com.cn>
Cc: Jiri Slaby <jslaby@suse.com>,
linux-kernel@vger.kernel.org, security@kernel.org,
Tony Lindgren <tony@atomide.com>,
Lars Poeschel <poeschel@lemonage.de>,
Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 4/4] tty: n_gsm: Fix the test for if DLCI0 is open
Date: Thu, 26 Apr 2018 08:54:21 +0300 [thread overview]
Message-ID: <20180426055421.GB15363@mwanda> (raw)
In-Reply-To: <20180420083028.7fq3hw2mjjd7nrra@mwanda>
Logically, if gsm->dlci[0] is NULL then it's not open. Also if it's
NULL then we would Oops when we do dlci_get(gsm->dlci[0]); at the end
of the function.
Reported-by: Sun Peng <sun_peng@topsec.com.cn>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 44e9c5e3dbc1..660153538ca7 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2919,7 +2919,7 @@ static int gsmtty_install(struct tty_driver *driver, struct tty_struct *tty)
perspective as we don't have to worry about this
if DLCI0 is lost */
mutex_lock(&gsm->mutex);
- if (gsm->dlci[0] && gsm->dlci[0]->state != DLCI_OPEN) {
+ if (!gsm->dlci[0] || gsm->dlci[0]->state != DLCI_OPEN) {
mutex_unlock(&gsm->mutex);
return -EL2NSYNC;
}
prev parent reply other threads:[~2018-04-26 5:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180420083028.7fq3hw2mjjd7nrra@mwanda>
2018-04-26 5:52 ` [PATCH 1/4] tty: n_gsm: add some locking around gsm_mux[] Dan Carpenter
2018-04-26 9:27 ` Dan Carpenter
2018-04-26 5:53 ` [PATCH 2/4] tty: n_gsm: Prevent a potential use after free Dan Carpenter
2018-04-27 18:50 ` Tony Lindgren
2018-04-26 5:53 ` [PATCH 3/4] tty: n_gsm: Remove an unused lock Dan Carpenter
2018-04-26 5:54 ` Dan Carpenter [this message]
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=20180426055421.GB15363@mwanda \
--to=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=poeschel@lemonage.de \
--cc=s.hauer@pengutronix.de \
--cc=security@kernel.org \
--cc=sun_peng@topsec.com.cn \
--cc=tony@atomide.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.