* [PATCH] Fix incorrect memset in bnx2fc_parse_fcp_rsp
@ 2012-09-03 18:50 Andi Kleen
2012-09-04 1:21 ` Bhanu Prakash Gollapudi
0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2012-09-03 18:50 UTC (permalink / raw)
To: bprakash, linux-scsi, linux-kernel
gcc 4.8 warns because the memset only clears sizeof(char *) bytes, not
the whole buffer. Use the correct buffer size and clear the whole sense
buffer.
/backup/lsrc/git/linux-lto-2.6/drivers/scsi/bnx2fc/bnx2fc_io.c: In
function 'bnx2fc_parse_fcp_rsp':
/backup/lsrc/git/linux-lto-2.6/drivers/scsi/bnx2fc/bnx2fc_io.c:1810:41:
warning: argument to 'sizeof' in 'memset' call is the same expression as
the destination; did you mean to provide an explicit length?
[-Wsizeof-pointer-memaccess]
memset(sc_cmd->sense_buffer, 0, sizeof(sc_cmd->sense_buffer));
^
Signed-off-by: Andi Kleen <ak@linux.intel.com>
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 73f231c..8d4626c 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1807,7 +1807,7 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
fcp_sns_len = SCSI_SENSE_BUFFERSIZE;
}
- memset(sc_cmd->sense_buffer, 0, sizeof(sc_cmd->sense_buffer));
+ memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
if (fcp_sns_len)
memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix incorrect memset in bnx2fc_parse_fcp_rsp
2012-09-03 18:50 [PATCH] Fix incorrect memset in bnx2fc_parse_fcp_rsp Andi Kleen
@ 2012-09-04 1:21 ` Bhanu Prakash Gollapudi
0 siblings, 0 replies; 2+ messages in thread
From: Bhanu Prakash Gollapudi @ 2012-09-04 1:21 UTC (permalink / raw)
To: Andi Kleen; +Cc: linux-scsi, linux-kernel, James Bottomley
On 9/3/2012 11:50 AM, Andi Kleen wrote:
> gcc 4.8 warns because the memset only clears sizeof(char *) bytes, not
> the whole buffer. Use the correct buffer size and clear the whole sense
> buffer.
>
> /backup/lsrc/git/linux-lto-2.6/drivers/scsi/bnx2fc/bnx2fc_io.c: In
> function 'bnx2fc_parse_fcp_rsp':
> /backup/lsrc/git/linux-lto-2.6/drivers/scsi/bnx2fc/bnx2fc_io.c:1810:41:
> warning: argument to 'sizeof' in 'memset' call is the same expression as
> the destination; did you mean to provide an explicit length?
> [-Wsizeof-pointer-memaccess]
> memset(sc_cmd->sense_buffer, 0, sizeof(sc_cmd->sense_buffer));
> ^
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
>
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
> index 73f231c..8d4626c 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
> @@ -1807,7 +1807,7 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
> fcp_sns_len = SCSI_SENSE_BUFFERSIZE;
> }
>
> - memset(sc_cmd->sense_buffer, 0, sizeof(sc_cmd->sense_buffer));
> + memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
> if (fcp_sns_len)
> memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
>
>
Thanks Andi. Looks good to me.
Acked-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-04 1:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 18:50 [PATCH] Fix incorrect memset in bnx2fc_parse_fcp_rsp Andi Kleen
2012-09-04 1:21 ` Bhanu Prakash Gollapudi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).