From patchwork Thu Jul 23 13:01: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: 6853451 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 4B188C05AC for ; Thu, 23 Jul 2015 13:01:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DA6E2060D for ; Thu, 23 Jul 2015 13:01:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F7EF2061A for ; Thu, 23 Jul 2015 13:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753055AbbGWNBm (ORCPT ); Thu, 23 Jul 2015 09:01:42 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:33872 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752907AbbGWNB2 (ORCPT ); Thu, 23 Jul 2015 09:01:28 -0400 Received: by pdbbh15 with SMTP id bh15so111295411pdb.1 for ; Thu, 23 Jul 2015 06:01:27 -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; bh=xQtmraOiuOBbs3WGbF88lAfHaWDMu5bC3nQZjcHdgXs=; b=HCk18z5rV/AxZsAcic6DMof3I0ZgsS2/sHI9A6UqhDPfN3JjbwXEfv9SRvtrU6CXuA jNr0OiR/bnrgZb2VB4NtTLxnkg4Qgg6e/4FdyAqekWk0WBsLdrBFzJXL1D+XI66OJu7x 4aiWUfVNeU1npOD2qw10daDSln/8Cyg72JVQndKUwRBcvqiTDqZgq6JWw6lKngSFJTi3 YLRb7Kdvt0yUIecFAycR43PfnKuU2f6yZzpuAqC1vHvfJGDU+q7zuLimx0YS8cYrNdAE pkbNAPkMcUk7hcM3tvXfBkLPYLaP4TA2zcW45j9PkS4y3xV+3Z43CsYT4NLJ7lUoK2dT 7y8A== X-Received: by 10.66.117.135 with SMTP id ke7mr18607132pab.31.1437656486873; Thu, 23 Jul 2015 06:01:26 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id ym6sm9028824pac.32.2015.07.23.06.01.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jul 2015 06:01:26 -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 V2 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Date: Thu, 23 Jul 2015 22:01:18 +0900 Message-Id: <1437656479-6173-1-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 1.9.1 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 --- V2: use ! operator instead of NULL comparison 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..9c3ecaa 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) + 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) + 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) + 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) + return -ENOMEM; + WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);