[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20180426055421.GB15363@mwanda>
Date: Thu, 26 Apr 2018 08:54:21 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sun Peng <sun_peng@...sec.com.cn>
Cc: Jiri Slaby <jslaby@...e.com>, linux-kernel@...r.kernel.org,
security@...nel.org, Tony Lindgren <tony@...mide.com>,
Lars Poeschel <poeschel@...onage.de>,
Sascha Hauer <s.hauer@...gutronix.de>
Subject: [PATCH 4/4] tty: n_gsm: Fix the test for if DLCI0 is open
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@...sec.com.cn>
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.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;
}
Powered by blists - more mailing lists