MIPS: unsigned result >= 0 is always true
Subsystems (2)
PATCH 1/1 MIPS: unsigned result >= 0 is always true
unsigned result >= 0 is always true. Make sure that the return value is zero or more if atomic_sub is successful.
Signed-off-by Roel Kluin <[email protected]>
---
UNTESTED! please confirm whether this is the right fix.
arch/mips/include/asm/atomic.h +5 -4
@@ -248,7 +248,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)*/ static __inline__int atomic_sub_if_positive (int i,atomic_t * v) { -unsigned long result; +int result;smp_llsc_mb ();
@@ -296,9 +296,10 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)raw_local_irq_save (flags); result = v->counter; - result -= i; -if (result >=0 ) - v->counter = result; +if (v->counter >= i) + v->counter -= i; +else + result -= i;raw_local_irq_restore (flags); }