Skip to contentSkip to conversation

asm-generic: Fix 32 bit __generic_cmpxchg_local

PATCH Applied Stuart Menefy 2 participants 2 messages Jan 4, 2024 – Jan 5, 2024 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asm-generic: Fix 32 bit __generic_cmpxchg_local

From: David McKay <[email protected]>

Commit 656e9007ef58 ("asm-generic: avoid __generic_cmpxchg_local warnings") introduced a typo that means the code is incorrect for 32 bit values. It will work fine for postive numbers, but will fail for negative numbers on a system where longs are 64 bit.

Fixes 656e9007ef58 ("asm-generic: avoid __generic_cmpxchg_local warnings")
---
 include/asm-generic/cmpxchg-local.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/cmpxchg-local.h +1 -1
index 3df9f59a544e..f27d66fdc00a 100644
@@ -34,7 +34,7 @@ static inline unsigned long __generic_cmpxchg_local(volatile void *ptr,
 			*(u16 *)ptr = (new & 0xffffu);
 		break;
 	case 4: prev = *(u32 *)ptr;
-		if (prev == (old & 0xffffffffffu))
+		if (prev == (old & 0xffffffffu))
 			*(u32 *)ptr = (new & 0xffffffffu);
 		break;
 	case 8: prev = *(u64 *)ptr;
Signature · 1 line
2.39.3
maintainer Applied
#1 lore raw
Quoted 10 lines · Stuart Menefy

From: David McKay <[email protected]>

Commit 656e9007ef58 ("asm-generic: avoid __generic_cmpxchg_local warnings") introduced a typo that means the code is incorrect for 32 bit values. It will work fine for postive numbers, but will fail for negative numbers on a system where longs are 64 bit.

Fixes 656e9007ef58 ("asm-generic: avoid __generic_cmpxchg_local warnings")

Applied to the asm-generic tree, thanks a lot!

arnd