From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbdK1IB7 (ORCPT ); Tue, 28 Nov 2017 03:01:59 -0500 Received: from mga04.intel.com ([192.55.52.120]:2997 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751355AbdK1IBz (ORCPT ); Tue, 28 Nov 2017 03:01:55 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,467,1505804400"; d="scan'208";a="7078550" Date: Tue, 28 Nov 2017 16:00:56 +0800 From: kbuild test robot To: ishraq.i.ashraf@gmail.com Cc: kbuild-all@01.org, gregkh@linuxfoundation.org, himanshujha199640@gmail.com, goudapatilk@gmail.com, insafonov@gmail.com, dan.carpenter@oracle.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, johannes@sipsolutions.net, Ishraq Ibne Ashraf Subject: [PATCH] staging: rtl8188eu: fix kzalloc-simple.cocci warnings Message-ID: <20171128080056.GA1502@cairo> References: <1511634581-997-1-git-send-email-ishraq.i.ashraf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1511634581-997-1-git-send-email-ishraq.i.ashraf@gmail.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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:3379:36-43: WARNING: kzalloc should be used for pwep, 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 Fixes: f1ac2c75e0c6 ("staging: rtl8188eu: Fix private WEXT IOCTL calls") CC: Ishraq Ibne Ashraf Signed-off-by: Fengguang Wu --- ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -3376,14 +3376,13 @@ static int rtw_set_encryption_pvt(struct wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + offsetof(struct ndis_802_11_wep, KeyMaterial); - pwep = (struct ndis_802_11_wep *)kmalloc(wep_total_len, GFP_KERNEL); + pwep = kzalloc(wep_total_len, GFP_KERNEL); if (!pwep) { DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); ret = -ENOMEM; goto err_free_param; } - memset(pwep, 0, wep_total_len); pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; }