linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: fix kzalloc-simple.cocci warnings
       [not found] <201609081205.oaz2WLFu%fengguang.wu@intel.com>
@ 2016-09-08  4:22 ` kbuild test robot
  0 siblings, 0 replies; only message in thread
From: kbuild test robot @ 2016-09-08  4:22 UTC (permalink / raw)
  To: Michał Narajowski
  Cc: kbuild-all, Marcel Holtmann, Gustavo Padovan, Johan Hedberg,
	linux-bluetooth, netdev, linux-kernel

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);
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-09-08  4:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <201609081205.oaz2WLFu%fengguang.wu@intel.com>
2016-09-08  4:22 ` [PATCH] Bluetooth: fix kzalloc-simple.cocci warnings kbuild test robot

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).