af_iucv: fix race in __iucv_sock_wait()
authorHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Wed, 16 Sep 2009 04:37:25 +0000 (04:37 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Sep 2009 03:57:35 +0000 (20:57 -0700)
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 <brueckner@linux.vnet.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/iucv/af_iucv.c

index 3c915fb42917ded48ef62e242e60033144fba104..21ee68be02eec9ea896943961ed8a4ee55ee4e11 100644 (file)
@@ -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;                                          \