From patchwork Wed Oct 7 06:47:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fengguang Wu X-Patchwork-Id: 7342861 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 DAD629F1B9 for ; Wed, 7 Oct 2015 06:48:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3B012055A for ; Wed, 7 Oct 2015 06:48:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE0802054D for ; Wed, 7 Oct 2015 06:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149AbbJGGsk (ORCPT ); Wed, 7 Oct 2015 02:48:40 -0400 Received: from mga01.intel.com ([192.55.52.88]:25894 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbbJGGsj (ORCPT ); Wed, 7 Oct 2015 02:48:39 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 06 Oct 2015 23:48:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,647,1437462000"; d="scan'208";a="821175291" Received: from bee.sh.intel.com (HELO bee) ([10.239.97.14]) by fmsmga002.fm.intel.com with ESMTP; 06 Oct 2015 23:48:39 -0700 Received: from kbuild by bee with local (Exim 4.83) (envelope-from ) id 1ZjiWW-0008pt-RK; Wed, 07 Oct 2015 14:48:24 +0800 Date: Wed, 7 Oct 2015 14:47:46 +0800 From: kbuild test robot To: Glen Lee Cc: kbuild-all@01.org, Greg Kroah-Hartman , Tony Cho , Johnny Kim , Rachel Kim , Chris Park , Leo Kim , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: wilc1000: fix kzalloc-simple.cocci warnings Message-ID: <20151007064746.GA136537@lkp-hsx03> References: <201510071443.imssnv2G%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201510071443.imssnv2G%fengguang.wu@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: fengguang.wu@intel.com X-SA-Exim-Scanned: No (on bee); SAEximRunCond expanded to false Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 drivers/staging/wilc1000/host_interface.c:2852:15-22: WARNING: kzalloc should be used for pu8keybuf, instead of kmalloc/memset drivers/staging/wilc1000/host_interface.c:2904:15-22: WARNING: kzalloc should be used for pu8keybuf, instead of kmalloc/memset drivers/staging/wilc1000/host_interface.c:6596:15-22: WARNING: kzalloc should be used for pstrWFIDrv, instead of kmalloc/memset Use kzalloc rather than kmalloc followed by memset with 0 This considers some simple cases that are common and easy to validate Note in particular that there are no ...s in the rule, so all of the matched code has to be contiguous Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci CC: Glen Lee Signed-off-by: Fengguang Wu --- host_interface.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -2849,15 +2849,13 @@ static int Handle_Key(tstrWILC_WFIDrv *d case WPARxGtk: #ifdef WILC_AP_EXTERNAL_MLME if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) { - pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); + pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (pu8keybuf == NULL) { PRINT_ER("No buffer to send RxGTK Key\n"); ret = -1; goto _WPARxGtk_end_case_; } - memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN); - /*|----------------------------------------------------------------------------| * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key | @@ -2901,15 +2899,13 @@ static int Handle_Key(tstrWILC_WFIDrv *d if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) { PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n"); - pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); + pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (pu8keybuf == NULL) { PRINT_ER("No buffer to send RxGTK Key\n"); ret = -1; goto _WPARxGtk_end_case_; } - memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN); - /*|----------------------------------------------------------------------------| * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key | @@ -6593,14 +6589,13 @@ s32 host_int_init(tstrWILC_WFIDrv **phWF /*Allocate host interface private structure*/ - pstrWFIDrv = kmalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL); + pstrWFIDrv = kzalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL); if (pstrWFIDrv == NULL) { /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */ s32Error = WILC_NO_MEM; PRINT_ER("Failed to allocate memory\n"); goto _fail_timer_2; } - memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv)); /*return driver handle to user*/ *phWFIDrv = pstrWFIDrv; /*save into globl handle*/