Received: by 10.213.65.68 with SMTP id h4csp61015imn; Wed, 21 Mar 2018 12:22:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELt3Lg9ywG0Kk3Xl/BHSUJ6JhX6aYzdoIiEF4+bvmCXbLEXFtMO4kk8XyocDbk45a5fWfm5Q X-Received: by 10.98.17.210 with SMTP id 79mr11041256pfr.65.1521660169245; Wed, 21 Mar 2018 12:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521660169; cv=none; d=google.com; s=arc-20160816; b=OptAVex1Rlgxz1nMDEr5dPly9yhC9dg/T3c+qItcvSFVhKtT0txzzuzkgvb6eysmmA wyZZj/x5yrbybjk2hzqaDcsG96hvE4ilc9EHX0/XhLXDuhY7QG/fJOUcrqrsNOWTd5tm Jhnzmg06aa4yDIPkv7kxC2benQHAwcD00ad31VnAW0oDwrQuXxT/GGg8yAJvMM44YOrg OLoprD4/1NwV6MmQaxl+iBzl45XPbU3t3qjs/P3HVHWnRAG5yRTFVmaGc6GmYVHOjkmI I9rDCnhdE+n4ARKW0hUrvhLFy3aHztsvDkGlAhecy3Qvj/vZZ1hhhzTACn4XS3zwQJxG l4uw== 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 :message-id:date:subject:cc:to:from:arc-authentication-results; bh=aoZ0VdDRXB/CNiDfcQ4baEZGB52HyyI8JjX5laZs5VU=; b=AgnwTeF7QsztpH+ADcwufVjrjZjmkArlV1xXnOHZyYtdVA5vNMcCIexU1NDVcZ+uAC byps2EK5swPeb0fZojem39SunsGLLgL6/qNiQa9P1IdVy8AR4eRp2KIyLV4V6jpwj4rj Ra/WuTP8A9mH7huvNagR3A6ZOCSKaht2Hk/8Nn+lnei5zjpFY5EO17NMcquCHim9RBei n5aopXTSXFsWtrjxeVd7XdBbu4nKcScIcuZBS5r66dvNCinK5wJGbQT4w2U0XDgfGgkV axYOsQGw/1e2AgcEJsnKNRKL2bqI+3TboY+9J6JFGXm4plojr8TcGRd5x+/f3I/B1GU/ tDNQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 102-v6si4550168pla.230.2018.03.21.12.22.33; Wed, 21 Mar 2018 12:22:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753004AbeCUTTp (ORCPT + 99 others); Wed, 21 Mar 2018 15:19:45 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:54811 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbeCUTTo (ORCPT ); Wed, 21 Mar 2018 15:19:44 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1eyjGv-0002MI-PY; Wed, 21 Mar 2018 19:19:41 +0000 From: Colin King To: 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 Subject: [PATCH] staging: wilc1000: check for kmalloc allocation failures Date: Wed, 21 Mar 2018 19:19:41 +0000 Message-Id: <20180321191941.4126-1-colin.king@canonical.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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); -- 2.15.1