From patchwork Thu Jul 30 11:41:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 6902001 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA9EDC05AC for ; Thu, 30 Jul 2015 11:41:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4D4F20528 for ; Thu, 30 Jul 2015 11:41:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E38D520525 for ; Thu, 30 Jul 2015 11:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754534AbbG3LlW (ORCPT ); Thu, 30 Jul 2015 07:41:22 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:35598 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753822AbbG3LlV (ORCPT ); Thu, 30 Jul 2015 07:41:21 -0400 Received: by pdrg1 with SMTP id g1so23384696pdr.2 for ; Thu, 30 Jul 2015 04:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OHsAfAcTKDGRIAVm156fekFO4bN2YeoR/NR6dcAJFXM=; b=Y40/ukzTojzVnRcik4nEIuPUZfr28MPej3pl3DdACxUjzdCPirF7hyR85cf6LrkQBi Rpr2UBM+xunpHZBIVaCOmAs8PCJ9O91xZLE4dqcgp5GIhy5gk+r7nT88eJiFlh4Ynkuh 4stLnDF76rKdUGU2fRALBCs8RP1v9rkg+cx5MdorDfaaZ8ZaSA9gb3JX7tLPXA3EUeNG /mPoEVuseZOX9455GFgdsY7XHB68N3fDqaa2H6UQaXc5JWqIfbXsKoXZTvqPcTaRe7ip iA6rzAF1OKlpJvcgp3wZI2/l4B6GSxFnNXKJYz1xupZFBYwqKTJWgJaK/M24FZE/wNoY dUzg== X-Received: by 10.70.140.70 with SMTP id re6mr104206826pdb.87.1438256481232; Thu, 30 Jul 2015 04:41:21 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id or7sm1834117pdb.9.2015.07.30.04.41.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jul 2015 04:41:20 -0700 (PDT) From: Chaehyun Lim To: gregkh@linuxfoundation.org Cc: johnny.kim@atmel.com, rachel.kim@atmel.com, dean.lee@atmel.com, chris.park@atmel.com, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Chaehyun Lim Subject: [RESEND V2 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Date: Thu, 30 Jul 2015 20:41:04 +0900 Message-Id: <1438256465-19540-3-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438256465-19540-1-git-send-email-chaehyun.lim@gmail.com> References: <1438256465-19540-1-git-send-email-chaehyun.lim@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add error check if memory allocation is failed. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/coreconfigurator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 37e09b8..67cec9d 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -812,6 +812,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) u32 u32Tsf_Hi; pstrNetworkInfo = kmalloc(sizeof(tstrNetworkInfo), GFP_KERNEL); + if (!pstrNetworkInfo) + return -ENOMEM; + WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo)); pstrNetworkInfo->s8rssi = pu8WidVal[0]; @@ -862,6 +865,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) if (u16IEsLen > 0) { pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_KERNEL); + if (!pstrNetworkInfo->pu8IEs) + return -ENOMEM; + WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen); WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen); @@ -929,6 +935,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, u16 u16IEsLen = 0; pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL); + if (!pstrConnectRespInfo) + return -ENOMEM; + WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo)); /* u16AssocRespLen = pu8Buffer[0]; */ @@ -949,6 +958,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); pstrConnectRespInfo->pu8RespIEs = kmalloc(u16IEsLen, GFP_KERNEL); + if (!pstrConnectRespInfo->pu8RespIEs) + return -ENOMEM; + WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);