From: Greg KH on
2.6.34-stable review patch. If anyone has any objections, please let us know.


From: Will Deacon <will.deacon(a)>

commit 068de8d1be48a04b92fd97f76bb7e113b7be82a8 upstream.

The atomic64_add_unless function compares an atomic variable with
a given value and, if they are not equal, adds another given value
to the atomic variable. The function returns zero if the addition
did not occur and non-zero otherwise.

On ARM, the return value is initialised to 1 in C code. Inline assembly
code then performs the atomic64_add_unless operation, setting the
return value to 0 iff the addition does not occur. This means that
when the addition *does* occur, the value of ret must be preserved
across the inline assembly and therefore requires a "+r" constraint
rather than the current one of "=&r".

Thanks to Nicolas Pitre for helping to spot this.

Reviewed-by: Nicolas Pitre <nicolas.pitre(a)>
Signed-off-by: Will Deacon <will.deacon(a)>
Signed-off-by: Russell King <rmk+kernel(a)>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)>

arch/arm/include/asm/atomic.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -440,7 +440,7 @@ static inline int atomic64_add_unless(at
" teq %2, #0\n"
" bne 1b\n"
- : "=&r" (val), "=&r" (ret), "=&r" (tmp)
+ : "=&r" (val), "+r" (ret), "=&r" (tmp)
: "r" (&v->counter), "r" (u), "r" (a)
: "cc");

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)
More majordomo info at
Please read the FAQ at