From: kbuild test robot <fengguang.wu@intel.com>
To: "Michał Narajowski" <michal.narajowski@codecoup.pl>
Cc: kbuild-all@01.org, Marcel Holtmann <marcel@holtmann.org>,
Gustavo Padovan <gustavo@padovan.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] Bluetooth: fix kzalloc-simple.cocci warnings
Date: Thu, 8 Sep 2016 12:22:21 +0800 [thread overview]
Message-ID: <20160908042221.GA152443@ivytown2> (raw)
In-Reply-To: <201609081205.oaz2WLFu%fengguang.wu@intel.com>
net/bluetooth/mgmt.c:905:6-13: WARNING: kzalloc should be used for rp, 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: Michał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
mgmt.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -902,12 +902,10 @@ static int read_ext_controller_info(stru
eir_len = eir_append_data(buff, eir_len, EIR_NAME_SHORT,
hdev->short_name, name_len);
- rp = kmalloc(sizeof(*rp) + eir_len, GFP_KERNEL);
+ rp = kzalloc(sizeof(*rp) + eir_len, GFP_KERNEL);
if (!rp)
return -ENOMEM;
- memset(rp, 0, sizeof(*rp) + eir_len);
-
rp->eir_len = cpu_to_le16(eir_len);
memcpy(rp->eir, buff, eir_len);
parent reply other threads:[~2016-09-08 4:22 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <201609081205.oaz2WLFu%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=20160908042221.GA152443@ivytown2 \
--to=fengguang.wu@intel.com \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=kbuild-all@01.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=michal.narajowski@codecoup.pl \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).