From patchwork Fri Jan 24 09:26:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C377C2D0DB for ; Fri, 24 Jan 2020 11:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2136A214AF for ; Fri, 24 Jan 2020 11:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864278; bh=96w/q7FGFVWBnObjplNmoMiT9LhVX1lrLHcPImmRxuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NC7gr9dZK30LUjiQWodThJJQXKxmNIW4Vo/oO6HVirEuDI11eMzvvyA2+pPT71LsG MEMe2lILlOSXXnd7Qu0PkfY79UsfBwNRtaFSM9nUWwkRHmdhiO4FJakz53PkQ5FdQn mJBOM3eXKFasYH2lMclmcQ/rvWKNxGCgmYi88kQI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389889AbgAXLLR (ORCPT ); Fri, 24 Jan 2020 06:11:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:47138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389887AbgAXLLQ (ORCPT ); Fri, 24 Jan 2020 06:11:16 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0974D20708; Fri, 24 Jan 2020 11:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864275; bh=96w/q7FGFVWBnObjplNmoMiT9LhVX1lrLHcPImmRxuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=phRex/fNfns4xccNybD+gSS/Zkk2Uy3eJY2q+k6Ctqi03SxyCO4ZyjxBewaK1UfrO UbngkR5/vg2GK1oImuIJQuQw9S2eHyVqT4qFFYaMhYVQvpdeV+jzDmiF10FJLeZaNx AK7woB9p9ga7qcGc6h3vBKtEzqwf6juWff2b1mSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Sasha Levin Subject: [PATCH 4.19 209/639] staging: r8822be: check kzalloc return or bail Date: Fri, 24 Jan 2020 10:26:19 +0100 Message-Id: <20200124093113.188611943@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nicholas Mc Guire [ Upstream commit e4b08e16b7d9d030b6475ef48f94d734a39f3c81 ] 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") Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- .../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 53f55f129a760..ec742da030dba 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;