Skip to content

Commit fba7cd6

Browse files
Romain PerierKAGA-KOKO
authored andcommitted
asm-generic/futex: Re-enable preemption in futex_atomic_cmpxchg_inatomic()
The recent decoupling of pagefault disable and preempt disable added an explicit preempt_disable/enable() pair to the futex_atomic_cmpxchg_inatomic() implementation in asm-generic/futex.h. But it forgot to add preempt_enable() calls to the error handling code pathes, which results in a preemption count imbalance. This is observable on boot when the test for atomic_cmpxchg() is calling futex_atomic_cmpxchg_inatomic() on a NULL pointer. Add the missing preempt_enable() calls to the error handling code pathes. [ tglx: Massaged changelog ] Fixes: d9b9ff8 ("sched/preempt, futex: Disable preemption in UP futex_atomic_cmpxchg_inatomic() explicitly") Signed-off-by: Romain Perier <[email protected]> Cc: [email protected] Cc: Thomas Petazzoni <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent fe1bce9 commit fba7cd6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/asm-generic/futex.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
108108
u32 val;
109109

110110
preempt_disable();
111-
if (unlikely(get_user(val, uaddr) != 0))
111+
if (unlikely(get_user(val, uaddr) != 0)) {
112+
preempt_enable();
112113
return -EFAULT;
114+
}
113115

114-
if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
116+
if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
117+
preempt_enable();
115118
return -EFAULT;
119+
}
116120

117121
*uval = val;
118122
preempt_enable();

0 commit comments

Comments
 (0)