Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp846272imj; Fri, 15 Feb 2019 07:46:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IZMqBSFIeH7jjmz54wNwYnXbaobekjwRVM+JrS/fTudMQMyIj6513pK78zVcNwugfJrRXQP X-Received: by 2002:a17:902:7604:: with SMTP id k4mr9982725pll.232.1550245597988; Fri, 15 Feb 2019 07:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550245597; cv=none; d=google.com; s=arc-20160816; b=PLz502Emn5iNSoTI3YiOrDrDAvDcMnC0W4H8HkEfFpKe9FTyAvgo/f/tmLBZ89FFiq YF2LU6PM+CcjQKmQpOK58irpYbnHqBpWkUY028iNOb3CHEbclsHVG5gScVepSIDINGqc xhqVz3JU5fyIL6yrnDNMfzJKbChUEeCA1ITsRYz5W0vL/mRmTSGe/UWI5Rc3gwgs87Pz XbLZbMG6MPMfxHa0YB9qyefGFSXuS+DeqrN8QGCNYtVS0JBCoWzVNId9su9EBtclJwCs Knqe3VHdP9AUtQPj0/tetyukARa3mtL69Bjv4MBJ8uIdkvMd5vgmkicZcv9ERciX0XiU JRNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Q6LLRkW02dElV+16KgVXDBEsCyodnSttXb2h9jAK/Uc=; b=zulMez29/9cXx7SKjk+tqR1CQGDRDNxnns01S3jVeONs4Qi/wvaildTPYq4VGwMny2 aocpyiHcp026aKb1PPcrMTGozFlSPSmIn0+pfoUEH/sn3JPHPNPMbopiQSGadP3nNGvq cLjE8ImjTaOkkXrkhzsVb2v5mCk/ljicRks9jn59IANimBqSsE8tKR34KDEuTf0N0p0F JFlkSt8cT17h/++ZTj0FBPvWS1Yc97s0X4o3isOA5hlsh37Kn26E9NrzLD1WGiNV0ENT Oa/JPYLLmK6sDMpgo1xZK0/LFID2VXb+8pL856dnlcbNeZoJCmEUWbDnWgXblwSsie7U k5Mg== 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 31si6012227plg.291.2019.02.15.07.46.22; Fri, 15 Feb 2019 07:46:37 -0800 (PST) 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 S1732659AbfBOJ3V (ORCPT + 99 others); Fri, 15 Feb 2019 04:29:21 -0500 Received: from www.osadl.org ([62.245.132.105]:48240 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726113AbfBOJ3V (ORCPT ); Fri, 15 Feb 2019 04:29:21 -0500 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x1F9SssC031499; Fri, 15 Feb 2019 10:28:54 +0100 From: Nicholas Mc Guire To: Greg Kroah-Hartman Cc: Nathan Chancellor , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] staging: r8822be: check kzalloc return or bail Date: Fri, 15 Feb 2019 10:24:22 +0100 Message-Id: <1550222662-32124-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kzalloc() in halmac_parse_psd_data_88xx() can fail and return NULL so check the psd_set->data after allocation and if allocation failed return HALMAC_CMD_PROCESS_ERROR. Signed-off-by: Nicholas Mc Guire Fixes: 938a0447f094 ("staging: r8822be: Add code for halmac sub-drive") --- Problem was located with an experimental coccinelle script Patch was compile tested with: x86_64_defconfig + STAGING=y, R8822BE=m (with a smatch error that looks like a false-positive CHECK drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c:624 halmac_func_write_logical_efuse_88xx() error: uninitialized symbol 'pg_efuse_header2'. CC [M] drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.o as the initialization of pg_efuse_header2 is under the same if condition (line 592) as the use at line 624 it is initialized) Patch is agaisnt 5.0-rc6 (localversion-next is next-20190215) drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c index 53f55f12..bf783a0 100644 --- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c +++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c @@ -2466,8 +2466,11 @@ halmac_parse_psd_data_88xx(struct halmac_adapter *halmac_adapter, u8 *c2h_buf, segment_size = (u8)PSD_DATA_GET_SEGMENT_SIZE(c2h_buf); psd_set->data_size = total_size; - if (!psd_set->data) + if (!psd_set->data) { psd_set->data = kzalloc(psd_set->data_size, GFP_KERNEL); + if (!psd_set->data) + return HALMAC_CMD_PROCESS_ERROR; + } if (segment_id == 0) psd_set->segment_size = segment_size; -- 2.1.4