public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] asm-generic: Fix 32 bit __generic_cmpxchg_local
@ 2024-01-04  9:40 Stuart Menefy
  2024-01-05 22:25 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Stuart Menefy @ 2024-01-04  9:40 UTC (permalink / raw)
  To: Arnd Bergmann, linux-kernel; +Cc: linux-arch, David McKay

From: David McKay <david.mckay@codasip.com>

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")
Signed-off-by: David McKay <david.mckay@codasip.com>
Signed-off-by: Stuart Menefy <stuart.menefy@codasip.com>
---
 include/asm-generic/cmpxchg-local.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index 3df9f59a544e..f27d66fdc00a 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -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;
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] asm-generic: Fix 32 bit __generic_cmpxchg_local
  2024-01-04  9:40 [PATCH] asm-generic: Fix 32 bit __generic_cmpxchg_local Stuart Menefy
@ 2024-01-05 22:25 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2024-01-05 22:25 UTC (permalink / raw)
  To: Stuart Menefy, linux-kernel; +Cc: Linux-Arch, David McKay

On Thu, Jan 4, 2024, at 10:40, Stuart Menefy wrote:
> From: David McKay <david.mckay@codasip.com>
>
> 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")
> Signed-off-by: David McKay <david.mckay@codasip.com>
> Signed-off-by: Stuart Menefy <stuart.menefy@codasip.com>

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

      arnd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-05 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04  9:40 [PATCH] asm-generic: Fix 32 bit __generic_cmpxchg_local Stuart Menefy
2024-01-05 22:25 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox