arm64: atomic64_dec_if_positive: fix incorrect branch condition
authorWill Deacon <will.deacon@arm.com>
Fri, 29 May 2015 13:44:06 +0000 (14:44 +0100)
committerWill Deacon <will.deacon@arm.com>
Mon, 27 Jul 2015 14:28:54 +0000 (15:28 +0100)
If we attempt to atomic64_dec_if_positive on INT_MIN, we will underflow
and incorrectly decide that the original parameter was positive.

This patches fixes the broken condition code so that we handle this
corner case correctly.

Reviewed-by: Steve Capper <steve.capper@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/atomic_ll_sc.h
arch/arm64/include/asm/atomic_lse.h

index 5e2d1db3a1db56aec94cdf2a3bb45a9888719179..6671978e60fe591ae28a1f7e081d984a025ecddb 100644 (file)
@@ -159,7 +159,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v))
 "      prfm    pstl1strm, %2\n"
 "1:    ldxr    %0, %2\n"
 "      subs    %0, %0, #1\n"
-"      b.mi    2f\n"
+"      b.lt    2f\n"
 "      stlxr   %w1, %0, %2\n"
 "      cbnz    %w1, 1b\n"
 "      dmb     ish\n"
index 30e5cbcfc707cd2194215a44590f4f2eb9306c2f..f873bf61e17b10ca4ec88c6f7af2d7aca583b89f 100644 (file)
@@ -291,7 +291,7 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
        /* LSE atomics */
        "1:     ldr     x30, %[v]\n"
        "       subs    %[ret], x30, #1\n"
-       "       b.mi    2f\n"
+       "       b.lt    2f\n"
        "       casal   x30, %[ret], %[v]\n"
        "       sub     x30, x30, #1\n"
        "       sub     x30, x30, %[ret]\n"