From: Nicolas Pitre Date: Wed, 16 Nov 2005 15:05:11 +0000 (+0000) Subject: [ARM] 3165/1: fix atomic_cmpxchg() implementation for ARMv6+ X-Git-Tag: v2.6.15-rc2~68^2~7 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7d068336197945dc4af65c5973c996e526d51cb;p=linux-2.6 [ARM] 3165/1: fix atomic_cmpxchg() implementation for ARMv6+ Patch from Nicolas Pitre If 'old' and 'oldval' are different then 'res' never gets set. In that case, if ever %0 happened to contain anything but zero (rather likely) then the code will loop forever (or until another CPU just come along and change the atomic value to match 'old' which is rather unlikely). Signed-off-by: Nicolas Pitre Signed-off-by: Russell King --- diff --git a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h index 75b8027197..5f827509e9 100644 --- a/include/asm-arm/atomic.h +++ b/include/asm-arm/atomic.h @@ -87,6 +87,7 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) do { __asm__ __volatile__("@ atomic_cmpxchg\n" "ldrex %1, [%2]\n" + "mov %0, #0\n" "teq %1, %3\n" "strexeq %0, %4, [%2]\n" : "=&r" (res), "=&r" (oldval)