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_p...@topsec.com.cn>
Signed-off-by: Dan Carpenter <dan.carpen...@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;
        }

Reply via email to