1 From ffd9e147b120e9c2bf30ba4861860f1bc59362c5 Mon Sep 17 00:00:00 2001
2 From: Stas Sergeev <stsp@users.sourceforge.net>
3 Date: Thu, 14 Jun 2012 01:00:02 +0200
4 Subject: [PATCH] nptl: sh: fix race condition in lll_wait_tid
6 Make a local copy of the tid value to avoid a race condition,
7 as the value could have been changed to 0, thus using a pointer
8 it would have been passed to the lll_futex_wait modified.
10 Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
11 Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
12 (cherry picked from commit 0dcc13bf7a61b1d0708e5dd103d5515e0ffec79a)
14 Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
16 libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h | 6 +++---
17 1 file changed, 3 insertions(+), 3 deletions(-)
19 diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
20 index d10cd61..b83d863 100644
21 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
22 +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
23 @@ -396,9 +396,9 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden;
25 #define lll_wait_tid(tid) \
27 - __typeof (tid) *__tid = &(tid); \
28 - while (*__tid != 0) \
29 - lll_futex_wait (__tid, *__tid, LLL_SHARED); \
30 + __typeof (tid) __tid; \
31 + while ((__tid = (tid)) != 0) \
32 + lll_futex_wait (&(tid), __tid, LLL_SHARED); \
35 extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)