Re: [PATCH] asm-generic/futex: Properly re-enable preemption in futex_atomic_cmpxchg_inatomic()

Peter Zijlstra
2016-04-14T15:45:03Z

On Thu, Apr 14, 2016 at 03:36:03PM +0200, Romain Perier wrote:
> Fixes: d9b9ff8c1889 ("sched/preempt, futex: Disable preemption in UP futex_atomic_cmpxchg_inatomic() explicitly")
> Signed-off-by: Romain Perier <romain.perier@free-electrons.com>
> ---
> include/asm-generic/futex.h | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
> index e56272c..bf2d34c 100644
> --- a/include/asm-generic/futex.h
> +++ b/include/asm-generic/futex.h
> @@ -108,11 +108,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> u32 val;
>
> preempt_disable();
> - if (unlikely(get_user(val, uaddr) != 0))
> + if (unlikely(get_user(val, uaddr) != 0)) {
> + preempt_enable();
> return -EFAULT;
> + }
>
> - if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
> + if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
> + preempt_enable();
> return -EFAULT;
> + }
>
> *uval = val;
> preempt_enable();

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>