Skip to content

Commit

Permalink
bfa: Fix undefined bit shift on big-endian architectures with 32-bit …
Browse files Browse the repository at this point in the history
…DMA address

commit 03a6c3f upstream.

bfa_swap_words() shifts its argument (assumed to be 64-bit) by 32 bits
each way.  In two places the argument type is dma_addr_t, which may be
32-bit, in which case the effect of the bit shift is undefined:

drivers/scsi/bfa/bfa_fcpim.c: In function 'bfa_ioim_send_ioreq':
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: right shift count >= width of type [enabled by default]
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: right shift count >= width of type [enabled by default]

Avoid this by adding casts to u64 in bfa_swap_words().

Compile-tested only.

Signed-off-by: Ben Hutchings <[email protected]>
Reviewed-by: Martin K. Petersen <[email protected]>
Acked-by: Anil Gurumurthy <[email protected]>
Fixes: f16a175 ('[SCSI] bfa: remove all OS wrappers')
Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bwhacks authored and gregkh committed Sep 17, 2014
1 parent 2b1a024 commit e56febc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/bfa/bfa_ioc.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct bfa_sge_s {
} while (0)

#define bfa_swap_words(_x) ( \
((_x) << 32) | ((_x) >> 32))
((u64)(_x) << 32) | ((u64)(_x) >> 32))

#ifdef __BIG_ENDIAN
#define bfa_sge_to_be(_x)
Expand Down

0 comments on commit e56febc

Please sign in to comment.