From patchwork Mon Aug 17 02:05:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 7022831 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 8F9A4C05AC for ; Mon, 17 Aug 2015 02:05:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B94D22062E for ; Mon, 17 Aug 2015 02:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBCE72062C for ; Mon, 17 Aug 2015 02:05:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753461AbbHQCFj (ORCPT ); Sun, 16 Aug 2015 22:05:39 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34863 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125AbbHQCFi (ORCPT ); Sun, 16 Aug 2015 22:05:38 -0400 Received: by pacgr6 with SMTP id gr6so97255070pac.2 for ; Sun, 16 Aug 2015 19:05:37 -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=3xFKuxOsnKIQG2IiHPL2GJV/nW1frX3bHIgAKW118Ck=; b=DZiXt/suO84QoTRHm7ZRwelOdWdI6bh4k5+Ez6bKyh+1jvzCFhYjsHTPkucWTK11DU hbc/4/UCtlBlp/Ptbnydy+QwQXAFIb/vZqH3RFsoTh2yDhjKFyXIm0+melF4EETrmGGa KWFTybFY6wohLoxtP8JhFNauY4lERlpNe3r9mVv18PY9l+RhPwjcEEitiCmiImEjK62y RF8jTGJ0dfA6qqRUMV+91YjCJH29hDwv1xJPU9mLEHKHE+4IkG4n5iFXfiNkxLLY1M5v J73DLAIvx/5VPHzfT6z8LCmbmbiLr6b7oKECJb7F2If7DY6Kg8BycGTEMyiQ2s5F+qZL KE2A== X-Received: by 10.68.68.175 with SMTP id x15mr13719433pbt.10.1439777137908; Sun, 16 Aug 2015 19:05:37 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id tt8sm12609611pbc.49.2015.08.16.19.05.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Aug 2015 19:05:37 -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 6/6] staging: wilc1000: coreconfigurator.c: fix kmalloc error check Date: Mon, 17 Aug 2015 11:05:15 +0900 Message-Id: <1439777115-25861-6-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439777115-25861-1-git-send-email-chaehyun.lim@gmail.com> References: <1439777115-25861-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=-7.5 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 It is added and fixed error check when kmalloc is failed. Signed-off-by: Chaehyun Lim --- drivers/staging/wilc1000/coreconfigurator.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index f44d2ce..64b57c0 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -801,6 +801,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) u32 u32Tsf_Hi; pstrNetworkInfo = kmalloc(sizeof(tstrNetworkInfo), GFP_KERNEL); + if (!pstrNetworkInfo) + return -ENOMEM; + memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo)); pstrNetworkInfo->s8rssi = pu8WidVal[0]; @@ -851,6 +854,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo) if (u16IEsLen > 0) { pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_KERNEL); + if (!pstrNetworkInfo->pu8IEs) + return -ENOMEM; + memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen); memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen); @@ -918,6 +924,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen, u16 u16IEsLen = 0; pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL); + if (!pstrConnectRespInfo) + return -ENOMEM; + memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo)); /* u16AssocRespLen = pu8Buffer[0]; */ @@ -938,6 +947,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; + memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen); memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen); @@ -1008,10 +1020,8 @@ s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZ pstrSurveyResults = kmalloc_array(u32SurveyResultsCount, sizeof(wid_site_survey_reslts_s), GFP_KERNEL); - if (pstrSurveyResults == NULL) { - u32SurveyResultsCount = 0; - WILC_ERRORREPORT(s32Error, WILC_NO_MEM); - } + if (!pstrSurveyResults) + return -ENOMEM; memset((void *)(pstrSurveyResults), 0, u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));