public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/6] scsi: lpfc: Cocci spatch "pool_zalloc-simple"
       [not found] <1505974468535-2047238743-0-diffsplit-thomas@m3y3r.de>
  2017-09-21  6:15 ` [PATCH 6/6] scsi: Cocci spatch "pool_zalloc-simple" Thomas Meyer
@ 2017-09-21  6:15 ` Thomas Meyer
  2017-09-22 15:27   ` James Smart
  2017-09-25 23:06   ` Martin K. Petersen
  2017-09-21  6:15 ` [PATCH 4/6] mvsas: " Thomas Meyer
  2017-09-21  6:15 ` [PATCH 5/6] scsi: qla2xxx: " Thomas Meyer
  3 siblings, 2 replies; 8+ messages in thread
From: Thomas Meyer @ 2017-09-21  6:15 UTC (permalink / raw)
  To: james.smart, dick.kennedy, jejb, martin.petersen, linux-scsi,
	linux-kernel

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -1938,14 +1938,13 @@ lpfc_new_nvme_buf(struct lpfc_vport *vpo
 		 * pci bus space for an I/O. The DMA buffer includes the
 		 * number of SGE's necessary to support the sg_tablesize.
 		 */
-		lpfc_ncmd->data = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool,
-						 GFP_KERNEL,
-						 &lpfc_ncmd->dma_handle);
+		lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool,
+						  GFP_KERNEL,
+						  &lpfc_ncmd->dma_handle);
 		if (!lpfc_ncmd->data) {
 			kfree(lpfc_ncmd);
 			break;
 		}
-		memset(lpfc_ncmd->data, 0, phba->cfg_sg_dma_buf_size);
 
 		lxri = lpfc_sli4_next_xritag(phba);
 		if (lxri == NO_XRI) {

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

* [PATCH 4/6] mvsas: Cocci spatch "pool_zalloc-simple"
       [not found] <1505974468535-2047238743-0-diffsplit-thomas@m3y3r.de>
  2017-09-21  6:15 ` [PATCH 6/6] scsi: Cocci spatch "pool_zalloc-simple" Thomas Meyer
  2017-09-21  6:15 ` [PATCH 3/6] scsi: lpfc: " Thomas Meyer
@ 2017-09-21  6:15 ` Thomas Meyer
  2017-09-21  6:15 ` [PATCH 5/6] scsi: qla2xxx: " Thomas Meyer
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Meyer @ 2017-09-21  6:15 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi, linux-kernel

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -790,12 +790,11 @@ static int mvs_task_prep(struct sas_task
 	slot->n_elem = n_elem;
 	slot->slot_tag = tag;
 
-	slot->buf = dma_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
+	slot->buf = dma_pool_zalloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
 	if (!slot->buf) {
 		rc = -ENOMEM;
 		goto err_out_tag;
 	}
-	memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
 
 	tei.task = task;
 	tei.hdr = &mvi->slot[tag];

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

* [PATCH 5/6] scsi: qla2xxx: Cocci spatch "pool_zalloc-simple"
       [not found] <1505974468535-2047238743-0-diffsplit-thomas@m3y3r.de>
                   ` (2 preceding siblings ...)
  2017-09-21  6:15 ` [PATCH 4/6] mvsas: " Thomas Meyer
@ 2017-09-21  6:15 ` Thomas Meyer
  2017-09-22 17:25   ` Madhani, Himanshu
  2017-09-25 23:07   ` Martin K. Petersen
  3 siblings, 2 replies; 8+ messages in thread
From: Thomas Meyer @ 2017-09-21  6:15 UTC (permalink / raw)
  To: qla2xxx-upstream, jejb, martin.petersen, linux-scsi, linux-kernel

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -1116,14 +1116,13 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job
 		return -EINVAL;
 	}
 
-	mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
+	mn = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
 	if (!mn) {
 		ql_log(ql_log_warn, vha, 0x703c,
 		    "DMA alloc failed for fw buffer.\n");
 		return -ENOMEM;
 	}
 
-	memset(mn, 0, sizeof(struct access_chip_84xx));
 	mn->entry_type = ACCESS_CHIP_IOCB_TYPE;
 	mn->entry_count = 1;
 	ql84_mgmt = (void *)bsg_request + sizeof(struct fc_bsg_request);
diff -u -p a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -812,13 +812,12 @@ int qla24xx_async_gpdb(struct scsi_qla_h
 	sp->gen2 = fcport->login_gen;
 	qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
 
-	pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
+	pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
 	if (pd == NULL) {
 		ql_log(ql_log_warn, vha, 0xd043,
 		    "Failed to allocate port database structure.\n");
 		goto done_free_sp;
 	}
-	memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
 
 	mb = sp->u.iocb_cmd.u.mbx.out_mb;
 	mb[0] = MBC_GET_PORT_DATABASE;
diff -u -p a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1782,13 +1782,12 @@ qla2x00_get_port_database(scsi_qla_host_
 	    "Entered %s.\n", __func__);
 
 	pd24 = NULL;
-	pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
+	pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
 	if (pd  == NULL) {
 		ql_log(ql_log_warn, vha, 0x1050,
 		    "Failed to allocate port database structure.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
 
 	mcp->mb[0] = MBC_GET_PORT_DATABASE;
 	if (opt != 0 && !IS_FWI2_CAPABLE(ha))
@@ -2255,13 +2254,12 @@ qla24xx_login_fabric(scsi_qla_host_t *vh
 	else
 		req = ha->req_q_map[0];
 
-	lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
+	lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
 	if (lg == NULL) {
 		ql_log(ql_log_warn, vha, 0x1062,
 		    "Failed to allocate login IOCB.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(lg, 0, sizeof(struct logio_entry_24xx));
 
 	lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
 	lg->entry_count = 1;
@@ -2525,13 +2523,12 @@ qla24xx_fabric_logout(scsi_qla_host_t *v
 	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d,
 	    "Entered %s.\n", __func__);
 
-	lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
+	lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
 	if (lg == NULL) {
 		ql_log(ql_log_warn, vha, 0x106e,
 		    "Failed to allocate logout IOCB.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(lg, 0, sizeof(struct logio_entry_24xx));
 
 	req = vha->req;
 	lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
@@ -2820,13 +2817,12 @@ qla2x00_get_fcal_position_map(scsi_qla_h
 	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f,
 	    "Entered %s.\n", __func__);
 
-	pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
+	pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
 	if (pmap  == NULL) {
 		ql_log(ql_log_warn, vha, 0x1080,
 		    "Memory alloc failed.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(pmap, 0, FCAL_MAP_SIZE);
 
 	mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP;
 	mcp->mb[2] = MSW(pmap_dma);
@@ -3014,13 +3010,12 @@ qla24xx_abort_command(srb_t *sp)
 		return QLA_FUNCTION_FAILED;
 	}
 
-	abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
+	abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
 	if (abt == NULL) {
 		ql_log(ql_log_warn, vha, 0x108d,
 		    "Failed to allocate abort IOCB.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(abt, 0, sizeof(struct abort_entry_24xx));
 
 	abt->entry_type = ABORT_IOCB_TYPE;
 	abt->entry_count = 1;
@@ -3098,13 +3093,12 @@ __qla24xx_issue_tmf(char *name, uint32_t
 		rsp = req->rsp;
 	}
 
-	tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
+	tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
 	if (tsk == NULL) {
 		ql_log(ql_log_warn, vha, 0x1093,
 		    "Failed to allocate task management IOCB.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(tsk, 0, sizeof(struct tsk_mgmt_cmd));
 
 	tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
 	tsk->p.tsk.entry_count = 1;
@@ -3856,14 +3850,13 @@ qla24xx_modify_vp_config(scsi_qla_host_t
 	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb,
 	    "Entered %s.\n", __func__);
 
-	vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
+	vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
 	if (!vpmod) {
 		ql_log(ql_log_warn, vha, 0x10bc,
 		    "Failed to allocate modify VP IOCB.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
 
-	memset(vpmod, 0, sizeof(struct vp_config_entry_24xx));
 	vpmod->entry_type = VP_CONFIG_IOCB_TYPE;
 	vpmod->entry_count = 1;
 	vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS;
@@ -3934,13 +3927,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha,
 	if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
 		return QLA_PARAMETER_ERROR;
 
-	vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
+	vce = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
 	if (!vce) {
 		ql_log(ql_log_warn, vha, 0x10c2,
 		    "Failed to allocate VP control IOCB.\n");
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
-	memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
 
 	vce->entry_type = VP_CTRL_IOCB_TYPE;
 	vce->entry_count = 1;
@@ -6025,13 +6017,12 @@ int qla24xx_gpdb_wait(struct scsi_qla_ho
 	if (!vha->hw->flags.fw_started)
 		goto done;
 
-	pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
+	pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
 	if (pd  == NULL) {
 		ql_log(ql_log_warn, vha, 0xd047,
 		    "Failed to allocate port database structure.\n");
 		goto done_free_sp;
 	}
-	memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
 
 	memset(&mc, 0, sizeof(mc));
 	mc.mb[0] = MBC_GET_PORT_DATABASE;

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

* [PATCH 6/6] scsi: Cocci spatch "pool_zalloc-simple"
       [not found] <1505974468535-2047238743-0-diffsplit-thomas@m3y3r.de>
@ 2017-09-21  6:15 ` Thomas Meyer
  2017-09-21  6:15 ` [PATCH 3/6] scsi: lpfc: " Thomas Meyer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Meyer @ 2017-09-21  6:15 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, jejb, martin.petersen, linux-scsi,
	linux-kernel

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1651,13 +1651,12 @@ int qla4xxx_set_chap(struct scsi_qla_hos
 	uint32_t chap_size = 0;
 	dma_addr_t chap_dma;
 
-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
 	if (chap_table == NULL) {
 		ret =  -ENOMEM;
 		goto exit_set_chap;
 	}
 
-	memset(chap_table, 0, sizeof(struct ql4_chap_table));
 	if (bidi)
 		chap_table->flags |= BIT_6; /* peer */
 	else
diff -u -p a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -825,12 +825,10 @@ static int qla4xxx_delete_chap(struct Sc
 	uint32_t chap_size;
 	int ret = 0;
 
-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
 	if (chap_table == NULL)
 		return -ENOMEM;
 
-	memset(chap_table, 0, sizeof(struct ql4_chap_table));
-
 	if (is_qla80XX(ha))
 		max_chap_entries = (ha->hw.flt_chap_size / 2) /
 				   sizeof(struct ql4_chap_table);

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

* Re: [PATCH 3/6] scsi: lpfc: Cocci spatch "pool_zalloc-simple"
  2017-09-21  6:15 ` [PATCH 3/6] scsi: lpfc: " Thomas Meyer
@ 2017-09-22 15:27   ` James Smart
  2017-09-25 23:06   ` Martin K. Petersen
  1 sibling, 0 replies; 8+ messages in thread
From: James Smart @ 2017-09-22 15:27 UTC (permalink / raw)
  To: Thomas Meyer, dick.kennedy, jejb, martin.petersen, linux-scsi,
	linux-kernel

On 9/20/2017 11:15 PM, Thomas Meyer wrote:
> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
> Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>
>

Looks good. Thanks.

Signed-off-by: James Smart <james.smart@broadcom.com>

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

* Re: [PATCH 5/6] scsi: qla2xxx: Cocci spatch "pool_zalloc-simple"
  2017-09-21  6:15 ` [PATCH 5/6] scsi: qla2xxx: " Thomas Meyer
@ 2017-09-22 17:25   ` Madhani, Himanshu
  2017-09-25 23:07   ` Martin K. Petersen
  1 sibling, 0 replies; 8+ messages in thread
From: Madhani, Himanshu @ 2017-09-22 17:25 UTC (permalink / raw)
  To: Thomas Meyer
  Cc: Dept-Eng QLA2xxx Upstream, James E.J. Bottomley,
	Martin K . Petersen, Linux SCSI Mailinglist,
	linux-kernel@vger.kernel.org


> On Sep 20, 2017, at 11:15 PM, Thomas Meyer <thomas@m3y3r.de> wrote:
> 
> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
> Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
> 
> diff -u -p a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
> --- a/drivers/scsi/qla2xxx/qla_bsg.c
> +++ b/drivers/scsi/qla2xxx/qla_bsg.c
> @@ -1116,14 +1116,13 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job
> 		return -EINVAL;
> 	}
> 
> -	mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
> +	mn = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
> 	if (!mn) {
> 		ql_log(ql_log_warn, vha, 0x703c,
> 		    "DMA alloc failed for fw buffer.\n");
> 		return -ENOMEM;
> 	}
> 
> -	memset(mn, 0, sizeof(struct access_chip_84xx));
> 	mn->entry_type = ACCESS_CHIP_IOCB_TYPE;
> 	mn->entry_count = 1;
> 	ql84_mgmt = (void *)bsg_request + sizeof(struct fc_bsg_request);
> diff -u -p a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -812,13 +812,12 @@ int qla24xx_async_gpdb(struct scsi_qla_h
> 	sp->gen2 = fcport->login_gen;
> 	qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
> 
> -	pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
> +	pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
> 	if (pd == NULL) {
> 		ql_log(ql_log_warn, vha, 0xd043,
> 		    "Failed to allocate port database structure.\n");
> 		goto done_free_sp;
> 	}
> -	memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
> 
> 	mb = sp->u.iocb_cmd.u.mbx.out_mb;
> 	mb[0] = MBC_GET_PORT_DATABASE;
> diff -u -p a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
> --- a/drivers/scsi/qla2xxx/qla_mbx.c
> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
> @@ -1782,13 +1782,12 @@ qla2x00_get_port_database(scsi_qla_host_
> 	    "Entered %s.\n", __func__);
> 
> 	pd24 = NULL;
> -	pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
> +	pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
> 	if (pd  == NULL) {
> 		ql_log(ql_log_warn, vha, 0x1050,
> 		    "Failed to allocate port database structure.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
> 
> 	mcp->mb[0] = MBC_GET_PORT_DATABASE;
> 	if (opt != 0 && !IS_FWI2_CAPABLE(ha))
> @@ -2255,13 +2254,12 @@ qla24xx_login_fabric(scsi_qla_host_t *vh
> 	else
> 		req = ha->req_q_map[0];
> 
> -	lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
> +	lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
> 	if (lg == NULL) {
> 		ql_log(ql_log_warn, vha, 0x1062,
> 		    "Failed to allocate login IOCB.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(lg, 0, sizeof(struct logio_entry_24xx));
> 
> 	lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
> 	lg->entry_count = 1;
> @@ -2525,13 +2523,12 @@ qla24xx_fabric_logout(scsi_qla_host_t *v
> 	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d,
> 	    "Entered %s.\n", __func__);
> 
> -	lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
> +	lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
> 	if (lg == NULL) {
> 		ql_log(ql_log_warn, vha, 0x106e,
> 		    "Failed to allocate logout IOCB.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(lg, 0, sizeof(struct logio_entry_24xx));
> 
> 	req = vha->req;
> 	lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
> @@ -2820,13 +2817,12 @@ qla2x00_get_fcal_position_map(scsi_qla_h
> 	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f,
> 	    "Entered %s.\n", __func__);
> 
> -	pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
> +	pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
> 	if (pmap  == NULL) {
> 		ql_log(ql_log_warn, vha, 0x1080,
> 		    "Memory alloc failed.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(pmap, 0, FCAL_MAP_SIZE);
> 
> 	mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP;
> 	mcp->mb[2] = MSW(pmap_dma);
> @@ -3014,13 +3010,12 @@ qla24xx_abort_command(srb_t *sp)
> 		return QLA_FUNCTION_FAILED;
> 	}
> 
> -	abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
> +	abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
> 	if (abt == NULL) {
> 		ql_log(ql_log_warn, vha, 0x108d,
> 		    "Failed to allocate abort IOCB.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(abt, 0, sizeof(struct abort_entry_24xx));
> 
> 	abt->entry_type = ABORT_IOCB_TYPE;
> 	abt->entry_count = 1;
> @@ -3098,13 +3093,12 @@ __qla24xx_issue_tmf(char *name, uint32_t
> 		rsp = req->rsp;
> 	}
> 
> -	tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
> +	tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
> 	if (tsk == NULL) {
> 		ql_log(ql_log_warn, vha, 0x1093,
> 		    "Failed to allocate task management IOCB.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(tsk, 0, sizeof(struct tsk_mgmt_cmd));
> 
> 	tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
> 	tsk->p.tsk.entry_count = 1;
> @@ -3856,14 +3850,13 @@ qla24xx_modify_vp_config(scsi_qla_host_t
> 	ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb,
> 	    "Entered %s.\n", __func__);
> 
> -	vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
> +	vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
> 	if (!vpmod) {
> 		ql_log(ql_log_warn, vha, 0x10bc,
> 		    "Failed to allocate modify VP IOCB.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> 
> -	memset(vpmod, 0, sizeof(struct vp_config_entry_24xx));
> 	vpmod->entry_type = VP_CONFIG_IOCB_TYPE;
> 	vpmod->entry_count = 1;
> 	vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS;
> @@ -3934,13 +3927,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha,
> 	if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
> 		return QLA_PARAMETER_ERROR;
> 
> -	vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
> +	vce = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
> 	if (!vce) {
> 		ql_log(ql_log_warn, vha, 0x10c2,
> 		    "Failed to allocate VP control IOCB.\n");
> 		return QLA_MEMORY_ALLOC_FAILED;
> 	}
> -	memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
> 
> 	vce->entry_type = VP_CTRL_IOCB_TYPE;
> 	vce->entry_count = 1;
> @@ -6025,13 +6017,12 @@ int qla24xx_gpdb_wait(struct scsi_qla_ho
> 	if (!vha->hw->flags.fw_started)
> 		goto done;
> 
> -	pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
> +	pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
> 	if (pd  == NULL) {
> 		ql_log(ql_log_warn, vha, 0xd047,
> 		    "Failed to allocate port database structure.\n");
> 		goto done_free_sp;
> 	}
> -	memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
> 
> 	memset(&mc, 0, sizeof(mc));
> 	mc.mb[0] = MBC_GET_PORT_DATABASE;

Looks good.

Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>

Thanks,
- Himanshu

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

* Re: [PATCH 3/6] scsi: lpfc: Cocci spatch "pool_zalloc-simple"
  2017-09-21  6:15 ` [PATCH 3/6] scsi: lpfc: " Thomas Meyer
  2017-09-22 15:27   ` James Smart
@ 2017-09-25 23:06   ` Martin K. Petersen
  1 sibling, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2017-09-25 23:06 UTC (permalink / raw)
  To: Thomas Meyer
  Cc: james.smart, dick.kennedy, jejb, martin.petersen, linux-scsi,
	linux-kernel


Thomas,

> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
> Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Applied to 4.15/scsi-queue. Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 5/6] scsi: qla2xxx: Cocci spatch "pool_zalloc-simple"
  2017-09-21  6:15 ` [PATCH 5/6] scsi: qla2xxx: " Thomas Meyer
  2017-09-22 17:25   ` Madhani, Himanshu
@ 2017-09-25 23:07   ` Martin K. Petersen
  1 sibling, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2017-09-25 23:07 UTC (permalink / raw)
  To: Thomas Meyer
  Cc: qla2xxx-upstream, jejb, martin.petersen, linux-scsi, linux-kernel


Thomas,

> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
> Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Applied to 4.15/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2017-09-25 23:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1505974468535-2047238743-0-diffsplit-thomas@m3y3r.de>
2017-09-21  6:15 ` [PATCH 6/6] scsi: Cocci spatch "pool_zalloc-simple" Thomas Meyer
2017-09-21  6:15 ` [PATCH 3/6] scsi: lpfc: " Thomas Meyer
2017-09-22 15:27   ` James Smart
2017-09-25 23:06   ` Martin K. Petersen
2017-09-21  6:15 ` [PATCH 4/6] mvsas: " Thomas Meyer
2017-09-21  6:15 ` [PATCH 5/6] scsi: qla2xxx: " Thomas Meyer
2017-09-22 17:25   ` Madhani, Himanshu
2017-09-25 23:07   ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox