All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v3 31/31] elx: efct: Tie into kernel Kconfig and build process
@ 2020-04-12  7:22 kbuild test robot
  2020-04-12  7:22 ` [PATCH] elx: efct: fix zalloc-simple.cocci warnings kbuild test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: kbuild test robot @ 2020-04-12  7:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4474 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200412033303.29574-32-jsmart2021@gmail.com>
References: <20200412033303.29574-32-jsmart2021@gmail.com>
TO: James Smart <jsmart2021@gmail.com>
CC: linux-scsi(a)vger.kernel.org
CC: dwagner(a)suse.de, maier(a)linux.ibm.com, bvanassche(a)acm.org, herbszt(a)gmx.de, natechancellor(a)gmail.com, rdunlap(a)infradead.org, hare(a)suse.de, James Smart <jsmart2021@gmail.com>, Ram Vegesna <ram.vegesna@broadcom.com>

Hi James,

I love your patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next linus/master v5.6 next-20200412]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

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

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


coccinelle warnings: (new ones prefixed by >>)

>> drivers/scsi/elx/efct/efct_hw.c:3897:25-28: ERROR: reference preceded by free on line 3893
   drivers/scsi/elx/efct/efct_hw.c:3898:7-10: ERROR: reference preceded by free on line 3893
--
>> drivers/scsi/elx/efct/efct_hw.c:3882:7-14: WARNING: kzalloc should be used for ctx, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_hw.c:4509:7-14: WARNING: kzalloc should be used for cmd, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_hw.c:4595:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_hw.c:5306:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:3484:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:3385:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:5162:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:3122:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:3229:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:4827:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:5003:8-15: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:5096:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:4181:8-15: WARNING: kzalloc should be used for cmd, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_hw.c:4263:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_hw.c:3977:9-16: WARNING: kzalloc should be used for data, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_hw.c:532:18-25: WARNING: kzalloc should be used for hw -> wqe_buffs, instead of kmalloc/memset
--
>> drivers/scsi/elx/efct/efct_hw_queues.c:173:7-14: WARNING: kzalloc should be used for cq, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_hw_queues.c:376:7-14: WARNING: kzalloc should be used for rq, instead of kmalloc/memset
--
>> drivers/scsi/elx/efct/efct_lio.c:265:22-29: WARNING: kzalloc should be used for filp -> private_data, instead of kmalloc/memset
   drivers/scsi/elx/efct/efct_lio.c:303:22-29: WARNING: kzalloc should be used for filp -> private_data, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_lio.c:1462:11-18: WARNING: kzalloc should be used for wq_data, instead of kmalloc/memset
--
>> drivers/scsi/elx/efct/efct_xport.c:44:9-16: WARNING: kzalloc should be used for xport, instead of kmalloc/memset
>> drivers/scsi/elx/efct/efct_xport.c:688:12-19: WARNING: kzalloc should be used for payload, instead of kmalloc/memset

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
  2020-04-12  7:22 [PATCH v3 31/31] elx: efct: Tie into kernel Kconfig and build process kbuild test robot
@ 2020-04-12  7:22 ` kbuild test robot
  2020-04-12  7:22 ` kbuild test robot
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2020-04-12  7:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 9911 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200412033303.29574-32-jsmart2021@gmail.com>
References: <20200412033303.29574-32-jsmart2021@gmail.com>
TO: James Smart <jsmart2021@gmail.com>
CC: linux-scsi(a)vger.kernel.org
CC: dwagner(a)suse.de, maier(a)linux.ibm.com, bvanassche(a)acm.org, herbszt(a)gmx.de, natechancellor(a)gmail.com, rdunlap(a)infradead.org, hare(a)suse.de, James Smart <jsmart2021@gmail.com>, Ram Vegesna <ram.vegesna@broadcom.com>

From: kbuild test robot <lkp@intel.com>

drivers/scsi/elx/efct/efct_hw.c:3882:7-14: WARNING: kzalloc should be used for ctx, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:4509:7-14: WARNING: kzalloc should be used for cmd, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:4595:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:5306:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:3484:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:3385:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:5162:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:3122:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:3229:11-18: WARNING: kzalloc should be used for mbxdata, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:4827:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:5003:8-15: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:5096:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:4181:8-15: WARNING: kzalloc should be used for cmd, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:4263:7-14: WARNING: kzalloc should be used for buf, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:3977:9-16: WARNING: kzalloc should be used for data, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw.c:532:18-25: WARNING: kzalloc should be used for hw -> wqe_buffs, instead of kmalloc/memset


 Use zeroing allocator rather than allocator 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/zalloc-simple.cocci

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
---

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_hw.c |   61 +++++++++++++++++--------------------------------------------
 1 file changed, 17 insertions(+), 44 deletions(-)

--- a/drivers/scsi/elx/efct/efct_hw.c
+++ b/drivers/scsi/elx/efct/efct_hw.c
@@ -529,15 +529,12 @@ efct_hw_setup_io(struct efct_hw *hw)
 		}
 
 		/* Create WQE buffs for IO */
-		hw->wqe_buffs = kmalloc((hw->config.n_io *
-					     hw->sli.wqe_size),
-					     GFP_ATOMIC);
+		hw->wqe_buffs = kzalloc((hw->config.n_io * hw->sli.wqe_size),
+					GFP_ATOMIC);
 		if (!hw->wqe_buffs) {
 			kfree(hw->io);
 			return EFCT_HW_RTN_NO_MEMORY;
 		}
-		memset(hw->wqe_buffs, 0, (hw->config.n_io *
-					hw->sli.wqe_size));
 
 	} else {
 		/* re-use existing IOs, including SGLs */
@@ -3119,11 +3116,9 @@ efct_hw_get_sfp(struct efct_hw *hw, u16
 	struct efc_dma *dma;
 
 	/* mbxdata holds the header of the command */
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
-
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
 	/*
 	 * cb_arg holds the data that will be passed to the callback on
 	 * completion
@@ -3226,12 +3221,10 @@ efct_hw_get_temperature(struct efct_hw *
 	struct efct_hw_temp_cb_arg *cb_arg;
 	u8 *mbxdata;
 
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_KERNEL);
 	if (!cb_arg) {
 		kfree(mbxdata);
@@ -3382,12 +3375,10 @@ efct_hw_get_link_stats(struct efct_hw *h
 	struct efct_hw_link_stat_cb_arg *cb_arg;
 	u8 *mbxdata;
 
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_ATOMIC);
 	if (!cb_arg) {
 		kfree(mbxdata);
@@ -3481,12 +3472,10 @@ efct_hw_get_host_stats(struct efct_hw *h
 	struct efct_hw_host_stat_cb_arg *cb_arg;
 	u8 *mbxdata;
 
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_ATOMIC);
 	if (!cb_arg) {
 		kfree(mbxdata);
@@ -3879,11 +3868,10 @@ efct_hw_async_call(struct efct_hw *hw,
 	 * we need this to be persistent as the mbox cmd submission may be
 	 * queued and executed later execution.
 	 */
-	ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
+	ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(ctx, 0, sizeof(*ctx));
 	ctx->callback = callback;
 	ctx->arg = arg;
 
@@ -3974,14 +3962,13 @@ efct_hw_port_free_unreg_vpi(struct efc_s
 
 	/* Allocate memory and send unreg_vpi */
 	if (!data) {
-		data = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+		data = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 		if (!data) {
 			efct_hw_port_free_resources(sport,
 						    EFC_HW_PORT_FREE_FAIL,
 						    data);
 			return;
 		}
-		memset(data, 0, SLI4_BMBX_SIZE);
 	}
 
 	rc = sli_cmd_unreg_vpi(&hw->sli, data, SLI4_BMBX_SIZE,
@@ -4178,12 +4165,11 @@ efct_hw_port_alloc(struct efc *efc, stru
 	}
 
 	if (domain) {
-		cmd = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+		cmd = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 		if (!cmd) {
 			rc = EFCT_HW_RTN_NO_MEMORY;
 			goto efct_hw_port_alloc_out;
 		}
-		memset(cmd, 0, SLI4_BMBX_SIZE);
 
 		/*
 		 * If the WWPN is NULL, fetch the default
@@ -4260,11 +4246,10 @@ efct_hw_port_attach(struct efc *efc, str
 		return EFCT_HW_RTN_ERROR;
 	}
 
-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(buf, 0, SLI4_BMBX_SIZE);
 	sport->fc_id = fc_id;
 
 	rc = sli_cmd_reg_vpi(&hw->sli, buf, SLI4_BMBX_SIZE, sport->fc_id,
@@ -4506,12 +4491,10 @@ efct_hw_domain_alloc(struct efc *efc, st
 		return EFCT_HW_RTN_ERROR;
 	}
 
-	cmd = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	cmd = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!cmd)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(cmd, 0, SLI4_BMBX_SIZE);
-
 	/* allocate memory for the service parameters */
 	domain->dma.size = 112;
 	domain->dma.virt = dma_alloc_coherent(&efct->pcidev->dev,
@@ -4592,11 +4575,10 @@ efct_hw_domain_attach(struct efc *efc,
 		return EFCT_HW_RTN_ERROR;
 	}
 
-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(buf, 0, SLI4_BMBX_SIZE);
 	domain->sport->fc_id = fc_id;
 
 	rc = sli_cmd_reg_vfi(&hw->sli, buf, SLI4_BMBX_SIZE, domain->indicator,
@@ -4824,11 +4806,9 @@ efct_hw_node_attach(struct efc *efc, str
 		return EFCT_HW_RTN_ERROR;
 	}
 
-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;
-
-	memset(buf, 0, SLI4_BMBX_SIZE);
 	/*
 	 * If the attach count is non-zero, this RPI has already been reg'd.
 	 * Otherwise, register the RPI
@@ -5000,11 +4980,10 @@ efct_hw_node_detach(struct efc *efc, str
 		if (!rnode->attached)
 			return EFCT_HW_RTN_SUCCESS_SYNC;
 
-		buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+		buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 		if (!buf)
 			return EFCT_HW_RTN_NO_MEMORY;
 
-		memset(buf, 0, SLI4_BMBX_SIZE);
 		count = atomic_sub_return(1, &hw->rpi_ref[index].rpi_count);
 		count++;
 		if (count <= 1) {
@@ -5093,12 +5072,10 @@ efct_hw_node_free_all(struct efct_hw *hw
 		return EFCT_HW_RTN_ERROR;
 	}
 
-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(buf, 0, SLI4_BMBX_SIZE);
-
 	if (!sli_cmd_unreg_rpi(&hw->sli, buf, SLI4_BMBX_SIZE, 0xffff,
 			      SLI_RSRC_FCFI, U32_MAX))
 		rc = efct_hw_command(hw, buf, EFCT_CMD_NOWAIT,
@@ -5159,12 +5136,10 @@ efct_hw_get_nvparms(struct efct_hw *hw,
 	enum efct_hw_rtn rc = EFCT_HW_RTN_SUCCESS;
 
 	/* mbxdata holds the header of the command */
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	/*
 	 * cb_arg holds the data that will be passed to the callback on
 	 * completion
@@ -5303,12 +5278,10 @@ efct_hw_firmware_write_sli4_intf_2(struc
 	struct efct_hw_fw_wr_cb_arg *cb_arg;
 	int noc = 0;
 
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
 
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_KERNEL);
 	if (!cb_arg) {
 		kfree(mbxdata);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
  2020-04-12  7:22 [PATCH v3 31/31] elx: efct: Tie into kernel Kconfig and build process kbuild test robot
  2020-04-12  7:22 ` [PATCH] elx: efct: fix zalloc-simple.cocci warnings kbuild test robot
@ 2020-04-12  7:22 ` kbuild test robot
  2020-04-12  7:22 ` kbuild test robot
  2020-04-12  7:22 ` kbuild test robot
  3 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2020-04-12  7:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 2336 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200412033303.29574-32-jsmart2021@gmail.com>
References: <20200412033303.29574-32-jsmart2021@gmail.com>
TO: James Smart <jsmart2021@gmail.com>
CC: linux-scsi(a)vger.kernel.org
CC: dwagner(a)suse.de, maier(a)linux.ibm.com, bvanassche(a)acm.org, herbszt(a)gmx.de, natechancellor(a)gmail.com, rdunlap(a)infradead.org, hare(a)suse.de, James Smart <jsmart2021@gmail.com>, Ram Vegesna <ram.vegesna@broadcom.com>

From: kbuild test robot <lkp@intel.com>

drivers/scsi/elx/efct/efct_hw_queues.c:173:7-14: WARNING: kzalloc should be used for cq, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_hw_queues.c:376:7-14: WARNING: kzalloc should be used for rq, instead of kmalloc/memset


 Use zeroing allocator rather than allocator 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/zalloc-simple.cocci

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
---

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_hw_queues.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/scsi/elx/efct/efct_hw_queues.c
+++ b/drivers/scsi/elx/efct/efct_hw_queues.c
@@ -170,11 +170,10 @@ efct_hw_new_cq_set(struct hw_eq *eqs[],
 		cqs[i] = NULL;
 
 	for (i = 0; i < num_cqs; i++) {
-		cq = kmalloc(sizeof(*cq), GFP_KERNEL);
+		cq = kzalloc(sizeof(*cq), GFP_KERNEL);
 		if (!cq)
 			goto error;
 
-		memset(cq, 0, sizeof(*cq));
 		cqs[i]          = cq;
 		cq->eq          = eqs[i];
 		cq->type        = SLI_QTYPE_CQ;
@@ -373,11 +372,10 @@ efct_hw_new_rq_set(struct hw_cq *cqs[],
 		rqs[i] = NULL;
 
 	for (i = 0, q_count = 0; i < num_rq_pairs; i++, q_count += 2) {
-		rq = kmalloc(sizeof(*rq), GFP_KERNEL);
+		rq = kzalloc(sizeof(*rq), GFP_KERNEL);
 		if (!rq)
 			goto error;
 
-		memset(rq, 0, sizeof(*rq));
 		rqs[i] = rq;
 		rq->instance = hw->hw_rq_count++;
 		rq->cq = cqs[i];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
  2020-04-12  7:22 [PATCH v3 31/31] elx: efct: Tie into kernel Kconfig and build process kbuild test robot
  2020-04-12  7:22 ` [PATCH] elx: efct: fix zalloc-simple.cocci warnings kbuild test robot
  2020-04-12  7:22 ` kbuild test robot
@ 2020-04-12  7:22 ` kbuild test robot
  2020-04-12  7:22 ` kbuild test robot
  3 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2020-04-12  7:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 2987 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200412033303.29574-32-jsmart2021@gmail.com>
References: <20200412033303.29574-32-jsmart2021@gmail.com>
TO: James Smart <jsmart2021@gmail.com>
CC: linux-scsi(a)vger.kernel.org
CC: dwagner(a)suse.de, maier(a)linux.ibm.com, bvanassche(a)acm.org, herbszt(a)gmx.de, natechancellor(a)gmail.com, rdunlap(a)infradead.org, hare(a)suse.de, James Smart <jsmart2021@gmail.com>, Ram Vegesna <ram.vegesna@broadcom.com>

From: kbuild test robot <lkp@intel.com>

drivers/scsi/elx/efct/efct_lio.c:265:22-29: WARNING: kzalloc should be used for filp -> private_data, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_lio.c:303:22-29: WARNING: kzalloc should be used for filp -> private_data, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_lio.c:1462:11-18: WARNING: kzalloc should be used for wq_data, instead of kmalloc/memset


 Use zeroing allocator rather than allocator 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/zalloc-simple.cocci

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
---

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_lio.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -262,11 +262,10 @@ static int efct_debugfs_session_open(str
 		return EFC_SUCCESS;
 	}
 
-	filp->private_data = kmalloc(size, GFP_KERNEL);
+	filp->private_data = kzalloc(size, GFP_KERNEL);
 	if (!filp->private_data)
 		return -ENOMEM;
 
-	memset(filp->private_data, 0, size);
 	efct_lio_tgt_session_data(sport->efct, sport->wwpn, filp->private_data,
 				  size);
 	return EFC_SUCCESS;
@@ -300,11 +299,10 @@ static int efct_npiv_debugfs_session_ope
 		return EFC_SUCCESS;
 	}
 
-	filp->private_data = kmalloc(size, GFP_KERNEL);
+	filp->private_data = kzalloc(size, GFP_KERNEL);
 	if (!filp->private_data)
 		return -ENOMEM;
 
-	memset(filp->private_data, 0, size);
 	efct_lio_tgt_session_data(sport->efct, sport->npiv_wwpn,
 				  filp->private_data, size);
 	return EFC_SUCCESS;
@@ -1459,11 +1457,10 @@ int efct_scsi_del_initiator(struct efc *
 	if (reason == EFCT_SCSI_INITIATOR_MISSING)
 		return EFCT_SCSI_CALL_COMPLETE;
 
-	wq_data = kmalloc(sizeof(*wq_data), GFP_ATOMIC);
+	wq_data = kzalloc(sizeof(*wq_data), GFP_ATOMIC);
 	if (!wq_data)
 		return EFCT_SCSI_CALL_COMPLETE;
 
-	memset(wq_data, 0, sizeof(*wq_data));
 	wq_data->ptr = node;
 	wq_data->efct = efct;
 	INIT_WORK(&wq_data->work, efct_lio_remove_session);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
  2020-04-12  7:22 [PATCH v3 31/31] elx: efct: Tie into kernel Kconfig and build process kbuild test robot
                   ` (2 preceding siblings ...)
  2020-04-12  7:22 ` kbuild test robot
@ 2020-04-12  7:22 ` kbuild test robot
  3 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2020-04-12  7:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 2255 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200412033303.29574-32-jsmart2021@gmail.com>
References: <20200412033303.29574-32-jsmart2021@gmail.com>
TO: James Smart <jsmart2021@gmail.com>
CC: linux-scsi(a)vger.kernel.org
CC: dwagner(a)suse.de, maier(a)linux.ibm.com, bvanassche(a)acm.org, herbszt(a)gmx.de, natechancellor(a)gmail.com, rdunlap(a)infradead.org, hare(a)suse.de, James Smart <jsmart2021@gmail.com>, Ram Vegesna <ram.vegesna@broadcom.com>

From: kbuild test robot <lkp@intel.com>

drivers/scsi/elx/efct/efct_xport.c:44:9-16: WARNING: kzalloc should be used for xport, instead of kmalloc/memset
drivers/scsi/elx/efct/efct_xport.c:688:12-19: WARNING: kzalloc should be used for payload, instead of kmalloc/memset


 Use zeroing allocator rather than allocator 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/zalloc-simple.cocci

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
---

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

--- a/drivers/scsi/elx/efct/efct_xport.c
+++ b/drivers/scsi/elx/efct/efct_xport.c
@@ -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;
 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:40 ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:40 UTC (permalink / raw)
  To: James Smart
  Cc: linux-scsi, dwagner, maier, bvanassche, herbszt, natechancellor,
	rdunlap, hare, James Smart, Ram Vegesna, kbuild-all

From: kbuild test robot <lkp@intel.com>

Use zeroing allocator rather than allocator followed by memset with 0

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

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

--- a/drivers/scsi/elx/efct/efct_xport.c
+++ b/drivers/scsi/elx/efct/efct_xport.c
@@ -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;


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:40 ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1426 bytes --]

From: kbuild test robot <lkp@intel.com>

Use zeroing allocator rather than allocator followed by memset with 0

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

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

--- a/drivers/scsi/elx/efct/efct_xport.c
+++ b/drivers/scsi/elx/efct/efct_xport.c
@@ -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;

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:39 ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:39 UTC (permalink / raw)
  To: James Smart
  Cc: linux-scsi, dwagner, maier, bvanassche, herbszt, natechancellor,
	rdunlap, hare, James Smart, Ram Vegesna, kbuild-all

Use zeroing allocator rather than allocator followed by memset with 0

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

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_lio.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -262,11 +262,10 @@ static int efct_debugfs_session_open(str
 		return EFC_SUCCESS;
 	}

-	filp->private_data = kmalloc(size, GFP_KERNEL);
+	filp->private_data = kzalloc(size, GFP_KERNEL);
 	if (!filp->private_data)
 		return -ENOMEM;

-	memset(filp->private_data, 0, size);
 	efct_lio_tgt_session_data(sport->efct, sport->wwpn, filp->private_data,
 				  size);
 	return EFC_SUCCESS;
@@ -300,11 +299,10 @@ static int efct_npiv_debugfs_session_ope
 		return EFC_SUCCESS;
 	}

-	filp->private_data = kmalloc(size, GFP_KERNEL);
+	filp->private_data = kzalloc(size, GFP_KERNEL);
 	if (!filp->private_data)
 		return -ENOMEM;

-	memset(filp->private_data, 0, size);
 	efct_lio_tgt_session_data(sport->efct, sport->npiv_wwpn,
 				  filp->private_data, size);
 	return EFC_SUCCESS;
@@ -1459,11 +1457,10 @@ int efct_scsi_del_initiator(struct efc *
 	if (reason == EFCT_SCSI_INITIATOR_MISSING)
 		return EFCT_SCSI_CALL_COMPLETE;

-	wq_data = kmalloc(sizeof(*wq_data), GFP_ATOMIC);
+	wq_data = kzalloc(sizeof(*wq_data), GFP_ATOMIC);
 	if (!wq_data)
 		return EFCT_SCSI_CALL_COMPLETE;

-	memset(wq_data, 0, sizeof(*wq_data));
 	wq_data->ptr = node;
 	wq_data->efct = efct;
 	INIT_WORK(&wq_data->work, efct_lio_remove_session);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:39 ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:39 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]

Use zeroing allocator rather than allocator followed by memset with 0

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

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_lio.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -262,11 +262,10 @@ static int efct_debugfs_session_open(str
 		return EFC_SUCCESS;
 	}

-	filp->private_data = kmalloc(size, GFP_KERNEL);
+	filp->private_data = kzalloc(size, GFP_KERNEL);
 	if (!filp->private_data)
 		return -ENOMEM;

-	memset(filp->private_data, 0, size);
 	efct_lio_tgt_session_data(sport->efct, sport->wwpn, filp->private_data,
 				  size);
 	return EFC_SUCCESS;
@@ -300,11 +299,10 @@ static int efct_npiv_debugfs_session_ope
 		return EFC_SUCCESS;
 	}

-	filp->private_data = kmalloc(size, GFP_KERNEL);
+	filp->private_data = kzalloc(size, GFP_KERNEL);
 	if (!filp->private_data)
 		return -ENOMEM;

-	memset(filp->private_data, 0, size);
 	efct_lio_tgt_session_data(sport->efct, sport->npiv_wwpn,
 				  filp->private_data, size);
 	return EFC_SUCCESS;
@@ -1459,11 +1457,10 @@ int efct_scsi_del_initiator(struct efc *
 	if (reason == EFCT_SCSI_INITIATOR_MISSING)
 		return EFCT_SCSI_CALL_COMPLETE;

-	wq_data = kmalloc(sizeof(*wq_data), GFP_ATOMIC);
+	wq_data = kzalloc(sizeof(*wq_data), GFP_ATOMIC);
 	if (!wq_data)
 		return EFCT_SCSI_CALL_COMPLETE;

-	memset(wq_data, 0, sizeof(*wq_data));
 	wq_data->ptr = node;
 	wq_data->efct = efct;
 	INIT_WORK(&wq_data->work, efct_lio_remove_session);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:38 ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:38 UTC (permalink / raw)
  To: James Smart
  Cc: linux-scsi, dwagner, maier, bvanassche, herbszt, natechancellor,
	rdunlap, hare, James Smart, Ram Vegesna, kbuild-all

From: kbuild test robot <lkp@intel.com>

Use zeroing allocator rather than allocator followed by memset with 0

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

There are four patches in all from 0-day, all with the same subject.
Maybe you can just squash them.

thanks,
julia

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_hw_queues.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/scsi/elx/efct/efct_hw_queues.c
+++ b/drivers/scsi/elx/efct/efct_hw_queues.c
@@ -170,11 +170,10 @@ efct_hw_new_cq_set(struct hw_eq *eqs[],
 		cqs[i] = NULL;

 	for (i = 0; i < num_cqs; i++) {
-		cq = kmalloc(sizeof(*cq), GFP_KERNEL);
+		cq = kzalloc(sizeof(*cq), GFP_KERNEL);
 		if (!cq)
 			goto error;

-		memset(cq, 0, sizeof(*cq));
 		cqs[i]          = cq;
 		cq->eq          = eqs[i];
 		cq->type        = SLI_QTYPE_CQ;
@@ -373,11 +372,10 @@ efct_hw_new_rq_set(struct hw_cq *cqs[],
 		rqs[i] = NULL;

 	for (i = 0, q_count = 0; i < num_rq_pairs; i++, q_count += 2) {
-		rq = kmalloc(sizeof(*rq), GFP_KERNEL);
+		rq = kzalloc(sizeof(*rq), GFP_KERNEL);
 		if (!rq)
 			goto error;

-		memset(rq, 0, sizeof(*rq));
 		rqs[i] = rq;
 		rq->instance = hw->hw_rq_count++;
 		rq->cq = cqs[i];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:38 ` Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:38 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]

From: kbuild test robot <lkp@intel.com>

Use zeroing allocator rather than allocator followed by memset with 0

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

There are four patches in all from 0-day, all with the same subject.
Maybe you can just squash them.

thanks,
julia

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_hw_queues.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/scsi/elx/efct/efct_hw_queues.c
+++ b/drivers/scsi/elx/efct/efct_hw_queues.c
@@ -170,11 +170,10 @@ efct_hw_new_cq_set(struct hw_eq *eqs[],
 		cqs[i] = NULL;

 	for (i = 0; i < num_cqs; i++) {
-		cq = kmalloc(sizeof(*cq), GFP_KERNEL);
+		cq = kzalloc(sizeof(*cq), GFP_KERNEL);
 		if (!cq)
 			goto error;

-		memset(cq, 0, sizeof(*cq));
 		cqs[i]          = cq;
 		cq->eq          = eqs[i];
 		cq->type        = SLI_QTYPE_CQ;
@@ -373,11 +372,10 @@ efct_hw_new_rq_set(struct hw_cq *cqs[],
 		rqs[i] = NULL;

 	for (i = 0, q_count = 0; i < num_rq_pairs; i++, q_count += 2) {
-		rq = kmalloc(sizeof(*rq), GFP_KERNEL);
+		rq = kzalloc(sizeof(*rq), GFP_KERNEL);
 		if (!rq)
 			goto error;

-		memset(rq, 0, sizeof(*rq));
 		rqs[i] = rq;
 		rq->instance = hw->hw_rq_count++;
 		rq->cq = cqs[i];

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] elx: efct: fix zalloc-simple.cocci warnings
@ 2020-04-12 15:33 Julia Lawall
  0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2020-04-12 15:33 UTC (permalink / raw)
  To: James Smart
  Cc: linux-scsi, dwagner, maier, bvanassche, herbszt, natechancellor,
	rdunlap, hare, James Smart, Ram Vegesna, kbuild

From: kbuild test robot <lkp@intel.com>

Use kzalloc instead of kmalloc/memset.

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

CC: James Smart <jsmart2021@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

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_hw.c |   61 +++++++++++++++++--------------------------------------------
 1 file changed, 17 insertions(+), 44 deletions(-)

--- a/drivers/scsi/elx/efct/efct_hw.c
+++ b/drivers/scsi/elx/efct/efct_hw.c
@@ -529,15 +529,12 @@ efct_hw_setup_io(struct efct_hw *hw)
 		}

 		/* Create WQE buffs for IO */
-		hw->wqe_buffs = kmalloc((hw->config.n_io *
-					     hw->sli.wqe_size),
-					     GFP_ATOMIC);
+		hw->wqe_buffs = kzalloc((hw->config.n_io * hw->sli.wqe_size),
+					GFP_ATOMIC);
 		if (!hw->wqe_buffs) {
 			kfree(hw->io);
 			return EFCT_HW_RTN_NO_MEMORY;
 		}
-		memset(hw->wqe_buffs, 0, (hw->config.n_io *
-					hw->sli.wqe_size));

 	} else {
 		/* re-use existing IOs, including SGLs */
@@ -3119,11 +3116,9 @@ efct_hw_get_sfp(struct efct_hw *hw, u16
 	struct efc_dma *dma;

 	/* mbxdata holds the header of the command */
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;
-
-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
 	/*
 	 * cb_arg holds the data that will be passed to the callback on
 	 * completion
@@ -3226,12 +3221,10 @@ efct_hw_get_temperature(struct efct_hw *
 	struct efct_hw_temp_cb_arg *cb_arg;
 	u8 *mbxdata;

-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_KERNEL);
 	if (!cb_arg) {
 		kfree(mbxdata);
@@ -3382,12 +3375,10 @@ efct_hw_get_link_stats(struct efct_hw *h
 	struct efct_hw_link_stat_cb_arg *cb_arg;
 	u8 *mbxdata;

-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_ATOMIC);
 	if (!cb_arg) {
 		kfree(mbxdata);
@@ -3481,12 +3472,10 @@ efct_hw_get_host_stats(struct efct_hw *h
 	struct efct_hw_host_stat_cb_arg *cb_arg;
 	u8 *mbxdata;

-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_ATOMIC);
 	if (!cb_arg) {
 		kfree(mbxdata);
@@ -3879,11 +3868,10 @@ efct_hw_async_call(struct efct_hw *hw,
 	 * we need this to be persistent as the mbox cmd submission may be
 	 * queued and executed later execution.
 	 */
-	ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
+	ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
 	if (!ctx)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(ctx, 0, sizeof(*ctx));
 	ctx->callback = callback;
 	ctx->arg = arg;

@@ -3974,14 +3962,13 @@ efct_hw_port_free_unreg_vpi(struct efc_s

 	/* Allocate memory and send unreg_vpi */
 	if (!data) {
-		data = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+		data = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 		if (!data) {
 			efct_hw_port_free_resources(sport,
 						    EFC_HW_PORT_FREE_FAIL,
 						    data);
 			return;
 		}
-		memset(data, 0, SLI4_BMBX_SIZE);
 	}

 	rc = sli_cmd_unreg_vpi(&hw->sli, data, SLI4_BMBX_SIZE,
@@ -4178,12 +4165,11 @@ efct_hw_port_alloc(struct efc *efc, stru
 	}

 	if (domain) {
-		cmd = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+		cmd = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 		if (!cmd) {
 			rc = EFCT_HW_RTN_NO_MEMORY;
 			goto efct_hw_port_alloc_out;
 		}
-		memset(cmd, 0, SLI4_BMBX_SIZE);

 		/*
 		 * If the WWPN is NULL, fetch the default
@@ -4260,11 +4246,10 @@ efct_hw_port_attach(struct efc *efc, str
 		return EFCT_HW_RTN_ERROR;
 	}

-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(buf, 0, SLI4_BMBX_SIZE);
 	sport->fc_id = fc_id;

 	rc = sli_cmd_reg_vpi(&hw->sli, buf, SLI4_BMBX_SIZE, sport->fc_id,
@@ -4506,12 +4491,10 @@ efct_hw_domain_alloc(struct efc *efc, st
 		return EFCT_HW_RTN_ERROR;
 	}

-	cmd = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	cmd = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!cmd)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(cmd, 0, SLI4_BMBX_SIZE);
-
 	/* allocate memory for the service parameters */
 	domain->dma.size = 112;
 	domain->dma.virt = dma_alloc_coherent(&efct->pcidev->dev,
@@ -4592,11 +4575,10 @@ efct_hw_domain_attach(struct efc *efc,
 		return EFCT_HW_RTN_ERROR;
 	}

-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(buf, 0, SLI4_BMBX_SIZE);
 	domain->sport->fc_id = fc_id;

 	rc = sli_cmd_reg_vfi(&hw->sli, buf, SLI4_BMBX_SIZE, domain->indicator,
@@ -4824,11 +4806,9 @@ efct_hw_node_attach(struct efc *efc, str
 		return EFCT_HW_RTN_ERROR;
 	}

-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;
-
-	memset(buf, 0, SLI4_BMBX_SIZE);
 	/*
 	 * If the attach count is non-zero, this RPI has already been reg'd.
 	 * Otherwise, register the RPI
@@ -5000,11 +4980,10 @@ efct_hw_node_detach(struct efc *efc, str
 		if (!rnode->attached)
 			return EFCT_HW_RTN_SUCCESS_SYNC;

-		buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+		buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 		if (!buf)
 			return EFCT_HW_RTN_NO_MEMORY;

-		memset(buf, 0, SLI4_BMBX_SIZE);
 		count = atomic_sub_return(1, &hw->rpi_ref[index].rpi_count);
 		count++;
 		if (count <= 1) {
@@ -5093,12 +5072,10 @@ efct_hw_node_free_all(struct efct_hw *hw
 		return EFCT_HW_RTN_ERROR;
 	}

-	buf = kmalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
+	buf = kzalloc(SLI4_BMBX_SIZE, GFP_ATOMIC);
 	if (!buf)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(buf, 0, SLI4_BMBX_SIZE);
-
 	if (!sli_cmd_unreg_rpi(&hw->sli, buf, SLI4_BMBX_SIZE, 0xffff,
 			      SLI_RSRC_FCFI, U32_MAX))
 		rc = efct_hw_command(hw, buf, EFCT_CMD_NOWAIT,
@@ -5159,12 +5136,10 @@ efct_hw_get_nvparms(struct efct_hw *hw,
 	enum efct_hw_rtn rc = EFCT_HW_RTN_SUCCESS;

 	/* mbxdata holds the header of the command */
-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	/*
 	 * cb_arg holds the data that will be passed to the callback on
 	 * completion
@@ -5303,12 +5278,10 @@ efct_hw_firmware_write_sli4_intf_2(struc
 	struct efct_hw_fw_wr_cb_arg *cb_arg;
 	int noc = 0;

-	mbxdata = kmalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
+	mbxdata = kzalloc(SLI4_BMBX_SIZE, GFP_KERNEL);
 	if (!mbxdata)
 		return EFCT_HW_RTN_NO_MEMORY;

-	memset(mbxdata, 0, SLI4_BMBX_SIZE);
-
 	cb_arg = kmalloc(sizeof(*cb_arg), GFP_KERNEL);
 	if (!cb_arg) {
 		kfree(mbxdata);

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-04-12 15:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12  7:22 [PATCH v3 31/31] elx: efct: Tie into kernel Kconfig and build process kbuild test robot
2020-04-12  7:22 ` [PATCH] elx: efct: fix zalloc-simple.cocci warnings kbuild test robot
2020-04-12  7:22 ` kbuild test robot
2020-04-12  7:22 ` kbuild test robot
2020-04-12  7:22 ` kbuild test robot
2020-04-12 15:33 Julia Lawall
2020-04-12 15:38 Julia Lawall
2020-04-12 15:38 ` Julia Lawall
2020-04-12 15:39 Julia Lawall
2020-04-12 15:39 ` Julia Lawall
2020-04-12 15:40 Julia Lawall
2020-04-12 15:40 ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.