* [PATCH] scsi: lpfc_nvme: Fix wrong sizeof argument
@ 2019-03-18 17:15 Gustavo A. R. Silva
2019-03-18 17:44 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-18 17:15 UTC (permalink / raw)
To: James Smart, Dick Kennedy, James E.J. Bottomley,
Martin K. Petersen
Cc: linux-scsi, linux-kernel, Gustavo A. R. Silva
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")
Fixes: 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQE setup")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/scsi/lpfc/lpfc_nvme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index d16ca413110d..3dc0c85c7d50 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -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);
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: lpfc_nvme: Fix wrong sizeof argument
2019-03-18 17:15 [PATCH] scsi: lpfc_nvme: Fix wrong sizeof argument Gustavo A. R. Silva
@ 2019-03-18 17:44 ` James Bottomley
2019-03-18 18:02 ` Gustavo A. R. Silva
2019-03-18 21:58 ` James Smart
0 siblings, 2 replies; 4+ messages in thread
From: James Bottomley @ 2019-03-18 17:44 UTC (permalink / raw)
To: Gustavo A. R. Silva, James Smart, Dick Kennedy,
Martin K. Petersen
Cc: linux-scsi, linux-kernel
On Mon, 2019-03-18 at 12:15 -0500, Gustavo A. R. Silva wrote:
> 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")
> Fixes: 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQE
> setup")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/scsi/lpfc/lpfc_nvme.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_nvme.c
> b/drivers/scsi/lpfc/lpfc_nvme.c
> index d16ca413110d..3dc0c85c7d50 100644
> --- a/drivers/scsi/lpfc/lpfc_nvme.c
> +++ b/drivers/scsi/lpfc/lpfc_nvme.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: lpfc_nvme: Fix wrong sizeof argument
2019-03-18 17:44 ` James Bottomley
@ 2019-03-18 18:02 ` Gustavo A. R. Silva
2019-03-18 21:58 ` James Smart
1 sibling, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-18 18:02 UTC (permalink / raw)
To: James Bottomley, James Smart, Dick Kennedy, Martin K. Petersen
Cc: linux-scsi, linux-kernel
On 3/18/19 12:44 PM, James Bottomley wrote:
> On Mon, 2019-03-18 at 12:15 -0500, Gustavo A. R. Silva wrote:
>> 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")
>> Fixes: 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQE
>> setup")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/scsi/lpfc/lpfc_nvme.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/lpfc/lpfc_nvme.c
>> b/drivers/scsi/lpfc/lpfc_nvme.c
>> index d16ca413110d..3dc0c85c7d50 100644
>> --- a/drivers/scsi/lpfc/lpfc_nvme.c
>> +++ b/drivers/scsi/lpfc/lpfc_nvme.c
>> @@ -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));
>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: lpfc_nvme: Fix wrong sizeof argument
2019-03-18 17:44 ` James Bottomley
2019-03-18 18:02 ` Gustavo A. R. Silva
@ 2019-03-18 21:58 ` James Smart
1 sibling, 0 replies; 4+ messages in thread
From: James Smart @ 2019-03-18 21:58 UTC (permalink / raw)
To: James Bottomley, Gustavo A. R. Silva, Dick Kennedy,
Martin K. Petersen
Cc: linux-scsi, linux-kernel
On 3/18/2019 10:44 AM, James Bottomley wrote:
> On Mon, 2019-03-18 at 12:15 -0500, Gustavo A. R. Silva wrote:
>> 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")
>> Fixes: 5fd1108517d9 ("scsi: lpfc: Streamline NVME Initiator WQE
>> setup")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/scsi/lpfc/lpfc_nvme.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/lpfc/lpfc_nvme.c
>> b/drivers/scsi/lpfc/lpfc_nvme.c
>> index d16ca413110d..3dc0c85c7d50 100644
>> --- a/drivers/scsi/lpfc/lpfc_nvme.c
>> +++ b/drivers/scsi/lpfc/lpfc_nvme.c
>> @@ -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
>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-18 21:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-18 17:15 [PATCH] scsi: lpfc_nvme: Fix wrong sizeof argument Gustavo A. R. Silva
2019-03-18 17:44 ` James Bottomley
2019-03-18 18:02 ` Gustavo A. R. Silva
2019-03-18 21:58 ` James Smart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox