Skip to contentSkip to conversation

Fix warning by coccicheck

PATCH Superseded Punit Vara 2 participants 6 messages Oct 23, 2015 – Oct 25, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Punit Vara

author
#0 lore raw

cover Fix warning by coccicheck

Punit Vara (2):
scsi: lpfc: Use kzalloc instead of kmalloc
scsi: remove useless casting value returned by kmalloc to structure

 drivers/scsi/hpsa.c          | 3 +--
 drivers/scsi/lpfc/lpfc_els.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.5.3
author
#1 lore raw

PATCH 1/2 scsi: lpfc: Use kzalloc instead of kmalloc

This patch is to the lpfc_els.c which resolves following warning reported by coccicheck:

WARNING: kzalloc should be used for rdp_context, instead of kmalloc/memset

---
 drivers/scsi/lpfc/lpfc_els.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +1 -1
index 36bf58b..422c800 100644
@@ -4990,7 +4990,7 @@ lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 	if (RDP_NPORT_ID_SIZE !=
 			be32_to_cpu(rdp_req->nport_id_desc.length))
 		goto rjt_logerr;
-	rdp_context = kmalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL);
+	rdp_context = kzalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL);
 	if (!rdp_context) {
 		rjt_err = LSRJT_UNABLE_TPC;
 		goto error;
Signature · 1 line
2.5.3
#2 lore raw

Re: [PATCH 1/2] scsi: lpfc: Use kzalloc instead of kmalloc

Hi Punit,

Aren't you missing the removal of the memset() as part of this conversion?

-matt

Quoted 26 lines · Punit Vara

This patch is to the lpfc_els.c which resolves following warning reported by coccicheck:

WARNING: kzalloc should be used for rdp_context, instead of kmalloc/memset

---
drivers/scsi/lpfc/lpfc_els.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_els.c +1 -1
index 36bf58b..422c800 100644
@@ -4990,7 +4990,7 @@ lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
 	if (RDP_NPORT_ID_SIZE !=
 			be32_to_cpu(rdp_req->nport_id_desc.length))
 		goto rjt_logerr;
-	rdp_context = kmalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL);
+	rdp_context = kzalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL);
 	if (!rdp_context) {
 		rjt_err = LSRJT_UNABLE_TPC;
 		goto error;
author
#3 lore raw

Re: [PATCH 1/2] scsi: lpfc: Use kzalloc instead of kmalloc

Quoted 20 lines · Matthew R. Ochs

Hi Punit,

Aren't you missing the removal of the memset() as part of this conversion?

-matt

Quoted 13 lines · Punit Vara

This patch is to the lpfc_els.c which resolves following warning reported by coccicheck:

WARNING: kzalloc should be used for rdp_context, instead of kmalloc/memset

---
drivers/scsi/lpfc/lpfc_els.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

drivers/scsi/lpfc/lpfc_els.c lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · line 4996

Quoted 13 lines
drivers/scsi/lpfc/lpfc_els.c +1 -1
index 36bf58b..422c800 100644
@@ -4990,7 +4990,7 @@ lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
      if (RDP_NPORT_ID_SIZE !=
                      be32_to_cpu(rdp_req->nport_id_desc.length))
              goto rjt_logerr;
-     rdp_context = kmalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL);
+     rdp_context = kzalloc(sizeof(struct lpfc_rdp_context), GFP_KERNEL);
      if (!rdp_context) {
              rjt_err = LSRJT_UNABLE_TPC;
              goto error;

Thanks for reviewing my patches.
Can I send more patches ? my all previous patches already reviewed by you . Should I wait to apply this patch to tree or i can send new patch set ? Please suggest me sir.

author
#4 lore raw

PATCH 2/2 scsi: remove useless casting value returned by kmalloc to structure

In reply to Punit Vara

This is the patch to the hpsa.c file that resolves following warning reported by coccicheck:

WARNING: casting value returned by memory allocation function to (BIG_IOCTL_Command_struct *) is useless.

---
 drivers/scsi/hpsa.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/hpsa.c +1 -2
index 40669f8..8d971b3 100644
@@ -6027,8 +6027,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
 		return -EINVAL;
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
-	ioc = (BIG_IOCTL_Command_struct *)
-	    kmalloc(sizeof(*ioc), GFP_KERNEL);
+	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
 	if (!ioc) {
 		status = -ENOMEM;
 		goto cleanup1;
Signature · 1 line
2.5.3