* [PATCH] [SCSI] bfa: Fix endian bug in bfad_iocmd_debug_fw_core().
@ 2012-03-06 17:06 santosh nayak
2012-03-09 18:51 ` Jing Huang
0 siblings, 1 reply; 2+ messages in thread
From: santosh nayak @ 2012-03-06 17:06 UTC (permalink / raw)
To: huangj
Cc: JBottomley, linux-scsi, linux-kernel, kernel-janitors, Santosh Nayak
From: Santosh Nayak <santoshprasadnayak@gmail.com>
Casting pointer from native data type to other type is
endian-sensitive.
"iocmd->offset" is 64 bit but we use only first 32 bit.
It works in little-endian system but in big-endian system
it will break.
Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
---
drivers/scsi/bfa/bfad_bsg.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 530de2b..c4edc63 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -1918,6 +1918,7 @@ bfad_iocmd_debug_fw_core(struct bfad_s *bfad, void *cmd,
struct bfa_bsg_debug_s *iocmd = (struct bfa_bsg_debug_s *)cmd;
void *iocmd_bufptr;
unsigned long flags;
+ u32 offset;
if (bfad_chk_iocmd_sz(payload_len, sizeof(struct bfa_bsg_debug_s),
BFA_DEBUG_FW_CORE_CHUNK_SZ) != BFA_STATUS_OK) {
@@ -1935,8 +1936,10 @@ bfad_iocmd_debug_fw_core(struct bfad_s *bfad, void *cmd,
iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_debug_s);
spin_lock_irqsave(&bfad->bfad_lock, flags);
+ offset = iocmd->offset;
iocmd->status = bfa_ioc_debug_fwcore(&bfad->bfa.ioc, iocmd_bufptr,
- (u32 *)&iocmd->offset, &iocmd->bufsz);
+ &offset, &iocmd->bufsz);
+ iocmd->offset = offset;
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
out:
return 0;
--
1.7.4.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH] [SCSI] bfa: Fix endian bug in bfad_iocmd_debug_fw_core().
2012-03-06 17:06 [PATCH] [SCSI] bfa: Fix endian bug in bfad_iocmd_debug_fw_core() santosh nayak
@ 2012-03-09 18:51 ` Jing Huang
0 siblings, 0 replies; 2+ messages in thread
From: Jing Huang @ 2012-03-09 18:51 UTC (permalink / raw)
To: santosh nayak
Cc: JBottomley, linux-scsi, linux-kernel, kernel-janitors, Krishna Gudipati
Change looks good to me. Thanks
Acked-by: Jing Huang <huangj@brocade.com>
>-----Original Message-----
>From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-owner@vger.kernel.org]
>On Behalf Of santosh nayak
>Sent: Tuesday, March 06, 2012 9:07 AM
>To: Jing Huang
>Cc: JBottomley@parallels.com; linux-scsi@vger.kernel.org; linux-
>kernel@vger.kernel.org; kernel-janitors@vger.kernel.org; Santosh Nayak
>Subject: [PATCH] [SCSI] bfa: Fix endian bug in bfad_iocmd_debug_fw_core().
>
>From: Santosh Nayak <santoshprasadnayak@gmail.com>
>
>Casting pointer from native data type to other type is
>endian-sensitive.
>
>"iocmd->offset" is 64 bit but we use only first 32 bit.
>It works in little-endian system but in big-endian system
>it will break.
>
>Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
>---
> drivers/scsi/bfa/bfad_bsg.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
>index 530de2b..c4edc63 100644
>--- a/drivers/scsi/bfa/bfad_bsg.c
>+++ b/drivers/scsi/bfa/bfad_bsg.c
>@@ -1918,6 +1918,7 @@ bfad_iocmd_debug_fw_core(struct bfad_s *bfad, void
>*cmd,
> struct bfa_bsg_debug_s *iocmd = (struct bfa_bsg_debug_s *)cmd;
> void *iocmd_bufptr;
> unsigned long flags;
>+ u32 offset;
>
> if (bfad_chk_iocmd_sz(payload_len, sizeof(struct bfa_bsg_debug_s),
> BFA_DEBUG_FW_CORE_CHUNK_SZ) !=
>BFA_STATUS_OK) {
>@@ -1935,8 +1936,10 @@ bfad_iocmd_debug_fw_core(struct bfad_s *bfad, void
>*cmd,
>
> iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_debug_s);
> spin_lock_irqsave(&bfad->bfad_lock, flags);
>+ offset = iocmd->offset;
> iocmd->status = bfa_ioc_debug_fwcore(&bfad->bfa.ioc, iocmd_bufptr,
>- (u32 *)&iocmd->offset, &iocmd->bufsz);
>+ &offset, &iocmd->bufsz);
>+ iocmd->offset = offset;
> spin_unlock_irqrestore(&bfad->bfad_lock, flags);
> out:
> return 0;
>--
>1.7.4.4
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-09 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-06 17:06 [PATCH] [SCSI] bfa: Fix endian bug in bfad_iocmd_debug_fw_core() santosh nayak
2012-03-09 18:51 ` Jing Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®