Skip to content

Commit 3da86ee

Browse files
author
Haavard Skinnemoen
committed
[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 <[email protected]>
1 parent f3e2698 commit 3da86ee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/asm-avr32/atomic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static inline int atomic_sub_unless(atomic_t *v, int a, int u)
101101
" mov %1, 1\n"
102102
"1:"
103103
: "=&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)
105105
: "cc", "memory");
106106

107107
return result;
@@ -137,7 +137,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
137137
" mov %1, 1\n"
138138
"1:"
139139
: "=&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)
141141
: "cc", "memory");
142142
}
143143

0 commit comments

Comments
 (0)