Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] bfa: Fix endian bug in bfad_iocmd_debug_fw_core().

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>
Acked-by: Jing Huang <huangj@brocade.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Santosh Nayak and committed by
James Bottomley
76c8ae4b 6d76222e

+4 -1
+4 -1
drivers/scsi/bfa/bfad_bsg.c
··· 1918 1918 struct bfa_bsg_debug_s *iocmd = (struct bfa_bsg_debug_s *)cmd; 1919 1919 void *iocmd_bufptr; 1920 1920 unsigned long flags; 1921 + u32 offset; 1921 1922 1922 1923 if (bfad_chk_iocmd_sz(payload_len, sizeof(struct bfa_bsg_debug_s), 1923 1924 BFA_DEBUG_FW_CORE_CHUNK_SZ) != BFA_STATUS_OK) { ··· 1936 1935 1937 1936 iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_debug_s); 1938 1937 spin_lock_irqsave(&bfad->bfad_lock, flags); 1938 + offset = iocmd->offset; 1939 1939 iocmd->status = bfa_ioc_debug_fwcore(&bfad->bfa.ioc, iocmd_bufptr, 1940 - (u32 *)&iocmd->offset, &iocmd->bufsz); 1940 + &offset, &iocmd->bufsz); 1941 + iocmd->offset = offset; 1941 1942 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1942 1943 out: 1943 1944 return 0;