From patchwork Thu Jul 23 23:55:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 6856561 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 C7B519F1D4 for ; Thu, 23 Jul 2015 23:56:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D7AC520601 for ; Thu, 23 Jul 2015 23:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F343520698 for ; Thu, 23 Jul 2015 23:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752687AbbGWX4I (ORCPT ); Thu, 23 Jul 2015 19:56:08 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35585 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752218AbbGWX4G (ORCPT ); Thu, 23 Jul 2015 19:56:06 -0400 Received: by pabkd10 with SMTP id kd10so4007104pab.2 for ; Thu, 23 Jul 2015 16:56:06 -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=ga5pCehk/Hn4Gq9OA2lp9IMEDVQ5eRnPYMlK8qUm7Ow=; b=hRLoEkwmbTiq+A6rjeJleiJvafLDQ8xVPWT9IcISx2eEX9MHbgKj9iL9IaGWSZlx3P wmkny1bXuc1mzTg8W+Zz04y5p69ULmNIpyeX42pqyJax95RHsj0ty9L7ejvfNiHyo6Dp zMYQKPsuzE7B2BJLRk1AjSjpqh4/MymQKiSF8T+HkW+j25x0iViJQQKb7/wBZSDCYHIR qUI+IVwAth7kwucD4qa8QCMK1/gCOVCnZmXivjwiStH2I+IKb6RWxHohx8ZWHeiW6MR4 86y37BRDp57QPtaTy3TRBLTZg6vI19f34plgAW+DRdsbhpf7OH+jYqu7wiYIyr+OxBNA 7Tqw== X-Received: by 10.66.120.201 with SMTP id le9mr23879553pab.142.1437695766304; Thu, 23 Jul 2015 16:56:06 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id r9sm6649481pdp.5.2015.07.23.16.56.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jul 2015 16:56:05 -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 V3 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Date: Fri, 24 Jul 2015 08:55:54 +0900 Message-Id: <1437695755-9731-2-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437695755-9731-1-git-send-email-chaehyun.lim@gmail.com> References: <1437695755-9731-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 --- V2: use ! operator instead of NULL comparison V3: this patch is rebased by previous modification 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 fb37367..0ff9705 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]; @@ -863,6 +866,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); @@ -930,6 +936,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]; */ @@ -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_KERNEL); + if (!pstrConnectRespInfo->pu8RespIEs) + return -ENOMEM; + WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);