From: Hendrik Brueckner Date: Wed, 16 Sep 2009 04:37:25 +0000 (+0000) Subject: af_iucv: fix race in __iucv_sock_wait() X-Git-Tag: firefly_0821_release~11864^2~335 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d9973179aef2af88b6fe4cc1df7ced6fe7cec7d0;p=firefly-linux-kernel-4.4.55.git af_iucv: fix race in __iucv_sock_wait() Moving prepare_to_wait before the condition to avoid a race between schedule_timeout and wake up. The race can appear during iucv_sock_connect() and iucv_callback_connack(). Signed-off-by: Hendrik Brueckner Signed-off-by: Ursula Braun Signed-off-by: David S. Miller --- diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 3c915fb42917..21ee68be02ee 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -59,8 +59,8 @@ do { \ DEFINE_WAIT(__wait); \ long __timeo = timeo; \ ret = 0; \ + prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \ while (!(condition)) { \ - prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \ if (!__timeo) { \ ret = -EAGAIN; \ break; \