Received: by 10.213.65.68 with SMTP id h4csp87571imn; Wed, 21 Mar 2018 13:05:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELt/q+idhAi19yFOn3ZsPLoY87WD5njxCBhkhhAkxxEx9QrBUc9ILDuqoRmVm/B2k1nRAUdY X-Received: by 2002:a17:902:20c2:: with SMTP id v2-v6mr22621595plg.82.1521662701516; Wed, 21 Mar 2018 13:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521662701; cv=none; d=google.com; s=arc-20160816; b=uWP/83j0q1rS5cn8kTECvrsM3f6LRYOcK7Y4jZ15Qh5gETzQxLKBwYYTUaiM7vi9gp PPA/DxGglLvag8G0FEhueCnWec8ZfB9oafXdeeO7VDF0+a9R9So4Dt+sZTJsiBmMMmyo MT2PgXdL3zw4RfYDYlEmFaWNhu7JzxbIu1Ux14X/oywr9jNqG05mtCALiwpNQdJwNXa8 3sAHxyxfsPjk3NZ2c+f+A8+VHnSSJfNUiwYwJwETMmkwFzqNqcLEHLcvrEacZQ6o6Xca /iOEvT68dEGoodgc0i2CH3sh5zpq0d3klrICWu4RbTyFkzftAlXV8RfYyh87lSlpX0cU iqqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=pWGahTaLx5cu0ExHr95dBymtsEzuxgY6YsIA2BvPB+o=; b=Lia3R6UkbpTqy85IxOZMa6aQpgTBsNrme6BPjOLv7VqSM3LaaBItjO/nIkwgonngLI OLBQZHSXWbY8KSRar3c+y4ZU3BIy7ESaU1Y+d6riZc8tM9Ih8ccaeqSoSTHMonSFAQIa fwGuD29YoPxTg909bR6euMtTdRexcw5wPtjMSGJV7i3TW1qSMeeed3sdHSP4DapLMqBL 7jKbqsxmhijgntr5Oe4UKxafuK5GNOCw65yIA0vJXRLr+U3xtm3LmclwOd2eOnJYn3r7 K8+HYyc69eD7W2gyEPDivHTqu8J6DxahtnhhJW/7MuepLhDjGUKL0+RHwf8prUVRZEFg EnQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si4501681plk.699.2018.03.21.13.04.47; Wed, 21 Mar 2018 13:05:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753282AbeCUUDY (ORCPT + 99 others); Wed, 21 Mar 2018 16:03:24 -0400 Received: from smtprelay0155.hostedemail.com ([216.40.44.155]:53752 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752954AbeCUUDX (ORCPT ); Wed, 21 Mar 2018 16:03:23 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id 62EDA180142EE; Wed, 21 Mar 2018 20:03:22 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3866:3867:3874:4321:4605:5007:6238:7208:7576:7903:8957:9113:10004:10400:10848:11026:11232:11658:11914:12043:12048:12296:12555:12740:12760:12895:12986:13069:13311:13357:13439:14093:14096:14097:14181:14659:14721:21080:21451:21627:30054:30070:30091,0,RBL:47.151.150.235:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:20,LUA_SUMMARY:none X-HE-Tag: mine16_5739574fbf835 X-Filterd-Recvd-Size: 2930 Received: from XPS-9350 (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Wed, 21 Mar 2018 20:03:19 +0000 (UTC) Message-ID: <1521662598.7999.33.camel@perches.com> Subject: Re: [PATCH] staging: wilc1000: check for kmalloc allocation failures From: Joe Perches To: Colin King , Aditya Shankar , Ganesh Krishna , Greg Kroah-Hartman , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 21 Mar 2018 13:03:18 -0700 In-Reply-To: <20180321191941.4126-1-colin.king@canonical.com> References: <20180321191941.4126-1-colin.king@canonical.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-03-21 at 19:19 +0000, Colin King wrote: > From: Colin Ian King > > There are three kmalloc allocations that are not null checked which > potentially could lead to null pointer dereference issues. Fix this > by adding null pointer return checks. looks like all of these should be kmemdup or kstrdup > Detected by CoverityScan, CID#1466025-27 ("Dereference null return") > > Signed-off-by: Colin Ian King > --- > drivers/staging/wilc1000/host_interface.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c > index 5082ede720f0..9b9b86654958 100644 > --- a/drivers/staging/wilc1000/host_interface.c > +++ b/drivers/staging/wilc1000/host_interface.c > @@ -944,6 +944,10 @@ static s32 handle_connect(struct wilc_vif *vif, > > if (conn_attr->bssid) { > hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL); > + if (!hif_drv->usr_conn_req.bssid) { > + result = -ENOMEM; > + goto error; > + } > memcpy(hif_drv->usr_conn_req.bssid, conn_attr->bssid, 6); > } > > @@ -951,6 +955,10 @@ static s32 handle_connect(struct wilc_vif *vif, > if (conn_attr->ssid) { > hif_drv->usr_conn_req.ssid = kmalloc(conn_attr->ssid_len + 1, > GFP_KERNEL); > + if (!hif_drv->usr_conn_req.ssid) { > + result = -ENOMEM; > + goto error; > + } > memcpy(hif_drv->usr_conn_req.ssid, > conn_attr->ssid, > conn_attr->ssid_len); > @@ -961,6 +969,10 @@ static s32 handle_connect(struct wilc_vif *vif, > if (conn_attr->ies) { > hif_drv->usr_conn_req.ies = kmalloc(conn_attr->ies_len, > GFP_KERNEL); > + if (!hif_drv->usr_conn_req.ies) { > + result = -ENOMEM; > + goto error; > + } > memcpy(hif_drv->usr_conn_req.ies, > conn_attr->ies, > conn_attr->ies_len);