Messages in this thread Patch in this message | | | Date | Thu, 26 Apr 2018 08:54:21 +0300 | From | Dan Carpenter <> | 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@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; }
| |