From 17db84eba18eaa20fab687bf38418a2286cb085a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vincent=20Stehl=C3=A9?= Date: Wed, 7 Oct 2015 07:08:25 +0200 Subject: [PATCH] staging: wilc1000: avoid NULL pointer dereference on error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Greg Kroah-Hartman --- 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 ba1d05d5e926..bb833d3cfd04 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -5861,7 +5861,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); -- 2.11.0