scsi: lpfc_nvme: Fix wrong sizeof argument
Subsystems (2)
PATCH 1/1 scsi: lpfc_nvme: Fix wrong sizeof argument
sizeof() is currently using the wrong argument when used in a call to memset(). Notice that wqe is a pointer to union lpfc_wqe128, not to union lpfc_wqe.
Fix this by using union lpfc_wqe128 instead of lpfc_wqe as argument of sizeof().
Addresses-Coverity-ID: 1443938 ("Wrong sizeof argument")
--- drivers/scsi/lpfc/lpfc_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_nvme.c +1 -1
@@ -1981,7 +1981,7 @@ lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,/* Fill in word 3 / sgl_len during cmd submission */ /* Initialize WQE */ -memset (wqe,0 ,sizeof (union lpfc_wqe )); +memset (wqe,0 ,sizeof (union lpfc_wqe128 ));if (lpfc_ndlp_check_qdepth (phba, ndlp)) {atomic_inc (&ndlp->cmd_pending);
Signature · 1 line
2.21.0
Quoted 22 lines · Gustavo A. R. Silva
sizeof()is currently using the wrong argument when used in a call tomemset(). Notice that wqe is a pointer to unionlpfc_wqe128, not to unionlpfc_wqe.Fix this by using union
lpfc_wqe128instead oflpfc_wqeas argument ofsizeof().Addresses-Coverity-ID: 1443938 ("Wrong sizeof argument")
Fixes 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQEsetup")
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/scsi/lpfc/lpfc_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_nvme.c +0
-0
drivers/scsi/lpfc/lpfc_nvme.c lpfc_get_nvme_buf(struct lpfc_hba *phba, struct · line 1985
Quoted 6 lines
drivers/scsi/lpfc/lpfc_nvme.c +1
-1@@ -1981,7 +1981,7 @@ lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,/* Fill in word 3 / sgl_len during cmd submission */ /* Initialize WQE */ -memset (wqe,0 ,sizeof (union lpfc_wqe )); +memset (wqe,0 ,sizeof (union lpfc_wqe128 ));
Actually the correct way to avoid potential problems like this is
memset(wqe, 0, sizeof(*wqe));
James
Quoted 26 lines · James Bottomley
Quoted 25 lines · Gustavo A. R. Silva
sizeof()is currently using the wrong argument when used in a call tomemset(). Notice that wqe is a pointer to unionlpfc_wqe128, not to unionlpfc_wqe.Fix this by using union
lpfc_wqe128instead oflpfc_wqeas argument ofsizeof().Addresses-Coverity-ID: 1443938 ("Wrong sizeof argument")
Fixes 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQEsetup")
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/scsi/lpfc/lpfc_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_nvme.c +0
-0@@ -1981,7 +1981,7 @@ lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,/* Fill in word 3 / sgl_len during cmd submission */
Quoted 8 lines
drivers/scsi/lpfc/lpfc_nvme.c lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · line 1984
Quoted 3 lines
drivers/scsi/lpfc/lpfc_nvme.c +1
-1/* Initialize WQE */ -memset (wqe,0 ,sizeof (union lpfc_wqe )); +memset (wqe,0 ,sizeof (union lpfc_wqe128 ));Actually the correct way to avoid potential problems like this is
memset(wqe, 0, sizeof(*wqe));
You,re right.
There are plenty of this kind of issues in lpfc.
I'll write a new patch to address all of them at once.
Thanks
--
Gustavo
Quoted 26 lines · James Bottomley
Quoted 25 lines · Gustavo A. R. Silva
sizeof()is currently using the wrong argument when used in a call tomemset(). Notice that wqe is a pointer to unionlpfc_wqe128, not to unionlpfc_wqe.Fix this by using union
lpfc_wqe128instead oflpfc_wqeas argument ofsizeof().Addresses-Coverity-ID: 1443938 ("Wrong sizeof argument")
Fixes 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQEsetup")
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/scsi/lpfc/lpfc_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/lpfc/lpfc_nvme.c +0
-0@@ -1981,7 +1981,7 @@ lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,/* Fill in word 3 / sgl_len during cmd submission */
Quoted 9 lines
drivers/scsi/lpfc/lpfc_nvme.c lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, · line 1984
Quoted 3 lines
drivers/scsi/lpfc/lpfc_nvme.c +1
-1/* Initialize WQE */ -memset (wqe,0 ,sizeof (union lpfc_wqe )); +memset (wqe,0 ,sizeof (union lpfc_wqe128 ));Actually the correct way to avoid potential problems like this is
memset(wqe, 0, sizeof(*wqe));James
Agree with James on style. This one reference was a little interesting. It purposely was something smaller than the whole structure as the latter end of the structure ends up getting set later. But not a big deal to correct as indicated.
--james