From patchwork Thu Jul 23 13:01:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaehyun Lim X-Patchwork-Id: 6853441 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 5E60B9F1D4 for ; Thu, 23 Jul 2015 13:01:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E50D2060D for ; Thu, 23 Jul 2015 13:01:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F8F920785 for ; Thu, 23 Jul 2015 13:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753038AbbGWNBi (ORCPT ); Thu, 23 Jul 2015 09:01:38 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:33186 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752970AbbGWNBa (ORCPT ); Thu, 23 Jul 2015 09:01:30 -0400 Received: by pdbnt7 with SMTP id nt7so85980129pdb.0 for ; Thu, 23 Jul 2015 06:01:30 -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=f9HhTsI3YHJcaXlykrjDlj+s0OhaO9ZpQlltLlnmWYw=; b=AQhcsO2pxBn2Eu8coURTNNSIbzRcJvO+o2ZQYK9Y5Z/OOqvppblemUmx9tlM0q2cg7 9SCqDlU7YK7K61R/H1oY2ctqM6blHQIpOeR3PqjCQHTEHqbHvCTyB+fft6MSqfhwGSgA zW7sgABo+eY+pPsi3bH+BB6SX2cGbP/dX3MD3EpBuwylfEqslt+czkr8wAiaT3G4PAdg 231SJ5KANR9voCxSVPK1FycVuydNQ441kCEVlRNSkpW+bYZweydK04ptVQnjlgS3UACF 5fp+9LlwBqjPSVTDbBohbsOtEXbbhXzDaBiRnIq8eDede24o6AjIkt4ekOeITaLxRCuD qvcA== X-Received: by 10.66.147.227 with SMTP id tn3mr18485724pab.130.1437656490037; Thu, 23 Jul 2015 06:01:30 -0700 (PDT) Received: from localhost.localdomain ([218.233.16.2]) by smtp.gmail.com with ESMTPSA id ym6sm9028824pac.32.2015.07.23.06.01.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jul 2015 06:01:29 -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 3/3] staging: wilc1000: coreconfigurator.c: fix kmalloc error check Date: Thu, 23 Jul 2015 22:01:19 +0900 Message-Id: <1437656479-6173-2-git-send-email-chaehyun.lim@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437656479-6173-1-git-send-email-chaehyun.lim@gmail.com> References: <1437656479-6173-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 Return -ENOMEM if memory allocation is failed. Signed-off-by: Chaehyun Lim --- V2: use ! operator instead of NULL comparison. drivers/staging/wilc1000/coreconfigurator.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 9c3ecaa..ff1eb5b 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -675,11 +675,8 @@ s32 CoreConfiguratorInit(void) sema_init(&SemHandlePktResp, 0); gps8ConfigPacket = kmalloc(MAX_PACKET_BUFF_SIZE, GFP_ATOMIC); - if (gps8ConfigPacket == NULL) { - PRINT_ER("failed in gps8ConfigPacket allocation\n"); - s32Error = WILC_NO_MEM; - goto _fail_; - } + if (!gps8ConfigPacket) + return -ENOMEM; WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE); @@ -1032,10 +1029,8 @@ s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZ pstrSurveyResults = kmalloc_array(u32SurveyResultsCount, sizeof(wid_site_survey_reslts_s), GFP_ATOMIC); - if (pstrSurveyResults == NULL) { - u32SurveyResultsCount = 0; - WILC_ERRORREPORT(s32Error, WILC_NO_MEM); - } + if (!pstrSurveyResults) + return -ENOMEM; WILC_memset((void *)(pstrSurveyResults), 0, u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));