Skip to contentSkip to conversation

elx: efct: fix zalloc-simple.cocci warnings

PATCH New Julia Lawall 1 participant 1 message Apr 12, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 elx: efct: fix zalloc-simple.cocci warnings

From: kbuild test robot <[email protected]>

Use zeroing allocator rather than allocator followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci

---

url:    https://github.com/0day-ci/linux/commits/James-Smart/efct-Broadcom-Emulex-FC-Target-driver/20200412-114125
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next

:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago

 efct_xport.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/elx/efct/efct_xport.c +2 -5
@@ -41,11 +41,10 @@ efct_xport_alloc(struct efct *efct)
 {
 	struct efct_xport *xport;
 
-	xport = kmalloc(sizeof(*xport), GFP_KERNEL);
+	xport = kzalloc(sizeof(*xport), GFP_KERNEL);
 	if (!xport)
 		return xport;
 
-	memset(xport, 0, sizeof(*xport));
 	xport->efct = efct;
 	return xport;
 }
@@ -685,12 +684,10 @@ efct_xport_control(struct efct_xport *xp
 		context = va_arg(argp, void *);
 		va_end(argp);
 
-		payload = kmalloc(sizeof(*payload), GFP_KERNEL);
+		payload = kzalloc(sizeof(*payload), GFP_KERNEL);
 		if (!payload)
 			return EFC_FAIL;
 
-		memset(payload, 0, sizeof(*payload));
-
 		efct = node->efc->base;
 		hw = &efct->hw;