Skip to content

Commit ff18143

Browse files
Pan XinhuiRich Felker
authored andcommitted
sh: cmpxchg: fix a bit shift bug in big_endian os
Correct bitoff in big endian OS. Current code works correctly for 1 byte but not for 2 bytes. Fixes: 3226aad ("sh: support 1 and 2 byte xchg") Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rich Felker <dalias@libc.org>
1 parent 7f155c7 commit ff18143

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎arch/sh/include/asm/cmpxchg-xchg.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static inline u32 __xchg_cmpxchg(volatile void *ptr, u32 x, int size)
2121
int off = (unsigned long)ptr % sizeof(u32);
2222
volatile u32 *p = ptr - off;
2323
#ifdef __BIG_ENDIAN
24-
int bitoff = (sizeof(u32) - 1 - off) * BITS_PER_BYTE;
24+
int bitoff = (sizeof(u32) - size - off) * BITS_PER_BYTE;
2525
#else
2626
int bitoff = off * BITS_PER_BYTE;
2727
#endif

0 commit comments

Comments
 (0)