Skip to content

Commit

Permalink
[ARM] 3165/1: fix atomic_cmpxchg() implementation for ARMv6+
Browse files Browse the repository at this point in the history
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 <nico@cam.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Nicolas Pitre authored and Russell King committed Nov 16, 2005
1 parent 224b5be commit a7d0683
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions include/asm-arm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a7d0683

Please sign in to comment.