From: kbuild test robot <fengguang.wu@intel.com>
To: Glen Lee <glen.lee@atmel.com>
Cc: kbuild-all@01.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tony Cho <tony.cho@atmel.com>, Johnny Kim <johnny.kim@atmel.com>,
Rachel Kim <rachel.kim@atmel.com>,
Chris Park <chris.park@atmel.com>, Leo Kim <leo.kim@atmel.com>,
linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] staging: wilc1000: fix kzalloc-simple.cocci warnings
Date: Wed, 7 Oct 2015 14:47:46 +0800 [thread overview]
Message-ID: <20151007064746.GA136537@lkp-hsx03> (raw)
In-Reply-To: <201510071443.imssnv2G%fengguang.wu@intel.com>
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 <glen.lee@atmel.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
host_interface.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
--- 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*/
parent reply other threads:[~2015-10-07 6:48 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <201510071443.imssnv2G%fengguang.wu@intel.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151007064746.GA136537@lkp-hsx03 \
--to=fengguang.wu@intel.com \
--cc=chris.park@atmel.com \
--cc=devel@driverdev.osuosl.org \
--cc=glen.lee@atmel.com \
--cc=gregkh@linuxfoundation.org \
--cc=johnny.kim@atmel.com \
--cc=kbuild-all@01.org \
--cc=leo.kim@atmel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=rachel.kim@atmel.com \
--cc=tony.cho@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox