From patchwork Wed Oct 7 05:08:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 7342451 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 386D89F1D5 for ; Wed, 7 Oct 2015 05:09:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5582C2066D for ; Wed, 7 Oct 2015 05:09:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A3B4205E2 for ; Wed, 7 Oct 2015 05:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752434AbbJGFIy (ORCPT ); Wed, 7 Oct 2015 01:08:54 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]:44355 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752031AbbJGFIx (ORCPT ); Wed, 7 Oct 2015 01:08:53 -0400 Received: from romuald.bergerie (unknown [88.178.86.202]) by smtp3-g21.free.fr (Postfix) with ESMTPS id 111C4A61A4; Wed, 7 Oct 2015 07:08:48 +0200 (CEST) Received: from radicelle.bergerie (radicelle.bergerie [192.168.124.12]) by romuald.bergerie (Postfix) with SMTP id 954BAE294A4; Wed, 7 Oct 2015 07:08:46 +0200 (CEST) Received: by radicelle.bergerie (sSMTP sendmail emulation); Wed, 07 Oct 2015 07:08:46 +0200 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= To: devel@driverdev.osuosl.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Vincent=20Stehl=C3=A9?= , Johnny Kim , Rachel Kim , Dean Lee , Chris Park , Nicolas Ferre , Greg Kroah-Hartman Subject: [PATCH next] staging: wilc1000: avoid NULL pointer dereference on error Date: Wed, 7 Oct 2015 07:08:25 +0200 Message-Id: <1444194505-31080-1-git-send-email-vincent.stehle@laposte.net> X-Mailer: git-send-email 2.5.1 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The host_int_init() function can dereference the pstrWFIDrv pointer while it is NULL on its error path. Jump directly to the _fail_ error label in the end of the error handling path to avoid that. By doing that we also skip stopping our kthread and destroying our message queue, but they were not started or created yet in that case anyway. This fixes the following coccinelle error: drivers/staging/wilc1000/host_interface.c:6100:17-33: ERROR: pstrWFIDrv is NULL but dereferenced. Signed-off-by: Vincent Stehlé Cc: Johnny Kim Cc: Rachel Kim Cc: Dean Lee Cc: Chris Park Cc: Nicolas Ferre Cc: Greg Kroah-Hartman --- Hi, Another form of this patch would make sense on mainline as well, but the driver has changed so much in the mean time that it makes more sense to modify staging-next. Best regards, V. drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2cf82b2..2fe3023 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -6017,7 +6017,7 @@ s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv) pstrWFIDrv = kzalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL); if (!pstrWFIDrv) { result = -ENOMEM; - goto _fail_timer_2; + goto _fail_; } *phWFIDrv = pstrWFIDrv; err = add_handler_in_list(pstrWFIDrv);