Commit 3da86ee4f1884c70edbf76f61bfbbe028d2d1685

Authored by Haavard Skinnemoen
1 parent f3e26984f1

[AVR32] Fix atomic_add_unless() and atomic_sub_unless()

These functions depend on "result" being initalized to 0, but "result"
is not included as an input constraint to the inline assembly block
following its initialization, only as an output constraint. Thus gcc
thinks it doesn't need to initialize it, so result ends up undefined
if the "unless" condition is true.

This fixes an oops in sunrpc where the faulty atomics caused
rpciod_up() to not start the workqueue as it should.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

include/asm-avr32/atomic.h
... ... @@ -101,7 +101,7 @@
101 101 " mov %1, 1\n"
102 102 "1:"
103 103 : "=&r"(tmp), "=&r"(result), "=o"(v->counter)
104   - : "m"(v->counter), "rKs21"(a), "rKs21"(u)
  104 + : "m"(v->counter), "rKs21"(a), "rKs21"(u), "1"(result)
105 105 : "cc", "memory");
106 106  
107 107 return result;
... ... @@ -137,7 +137,7 @@
137 137 " mov %1, 1\n"
138 138 "1:"
139 139 : "=&r"(tmp), "=&r"(result), "=o"(v->counter)
140   - : "m"(v->counter), "r"(a), "ir"(u)
  140 + : "m"(v->counter), "r"(a), "ir"(u), "1"(result)
141 141 : "cc", "memory");
142 142 }
143 143