From patchwork Thu Jul 23 11:19:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 6853031 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C7AD69F358 for ; Thu, 23 Jul 2015 11:19:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D231C2064C for ; Thu, 23 Jul 2015 11:19:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B71E520649 for ; Thu, 23 Jul 2015 11:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752848AbbGWLTf (ORCPT ); Thu, 23 Jul 2015 07:19:35 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33991 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752639AbbGWLTe (ORCPT ); Thu, 23 Jul 2015 07:19:34 -0400 Received: by pacan13 with SMTP id an13so157820782pac.1 for ; Thu, 23 Jul 2015 04:19:34 -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=j3tAsYq59dcUZrhb6O2pZYnlm6iuAvlt2vBl50xRPtM=; b=Xw8iuL/0C9RIQPtJvckOyxTHukUC49VJMNVUsdh+uSyrfMowIqON1PRfnv9V4iLriw rw91Fz+NQA5P4B7+KxHHD/P5lyszbTEa+6oSgIdzKkVeOGHE7XYzr4doS2efNdw9tkY4 0I3pkPWzEqZ0z7hxOoHM1mll19j7KGEJGXat0F96wZA+GZPYJ/8j8NqZIVGLUkLARXM3 dmDPwlhrcwZ2amHyb87KrstjrNFkJ8smRA5HeRCzjakdECCQyflfonrdL0KA7PVkYmOU UI/oOYKhByPd4pP1u9wRLi3xIBiAd3e9LCZwQ81PxQZGLjbyr7Vq9GuBJGxLWj0mMoQm Dp4w== X-Received: by 10.70.48.166 with SMTP id m6mr6031215pdn.13.1437650374215; Thu, 23 Jul 2015 04:19:34 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id oq10sm8400971pdb.75.2015.07.23.04.19.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jul 2015 04:19:33 -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: [PATCH 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Date: Thu, 23 Jul 2015 20:19:18 +0900 Message-Id: <1437650359-2051-2-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437650359-2051-1-git-send-email-chaehyun.lim@gmail.com> References: <1437650359-2051-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.0 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 7e2b2ab41..b51c15f 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_ATOMIC); + if (pstrNetworkInfo == NULL) + return -ENOMEM; + WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo)); pstrNetworkInfo->s8rssi = pu8WidVal[0]; @@ -863,6 +866,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) if (u16IEsLen > 0) { pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_ATOMIC); + if (pstrNetworkInfo->pu8IEs == NULL) + return -ENOMEM; + WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen); WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen); @@ -930,6 +936,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, u16 u16IEsLen = 0; pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_ATOMIC); + if (pstrConnectRespInfo == NULL) + return -ENOMEM; + WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo)); /* u16AssocRespLen = pu8Buffer[0]; */ @@ -950,6 +959,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN); pstrConnectRespInfo->pu8RespIEs = kmalloc(u16IEsLen, GFP_ATOMIC); + if (pstrConnectRespInfo->pu8RespIEs == NULL) + return -ENOMEM; + WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);