From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753634AbbIJLzN (ORCPT ); Thu, 10 Sep 2015 07:55:13 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35466 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465AbbIJLzI (ORCPT ); Thu, 10 Sep 2015 07:55:08 -0400 From: Sudip Mukherjee To: Lidza Louina , Mark Hounschell , Daeseok Youn , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, Sudip Mukherjee Subject: [PATCH 1/2] staging: dgap: fix possible NULL dereference Date: Thu, 10 Sep 2015 17:24:58 +0530 Message-Id: <1441886099-24399-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The return pointer from dgap_getword() is used in strcmp() where it is dereferenced. But dgap_getword() can return NULL. Lets put a check there and return 0 as error. Signed-off-by: Sudip Mukherjee --- drivers/staging/dgap/dgap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 9112dd2..20ba258 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -349,6 +349,8 @@ static int dgap_gettok(char **in) if (strstr(dgap_cword, "board")) { w = dgap_getword(in); + if (!w) + return 0; snprintf(dgap_cword, MAXCWORD, "%s", w); for (t = dgap_brdtype; t->token != 0; t++) { if (!strcmp(w, t->string)) -- 1.9.1