From: Peter Hurley Date: Sun, 24 Jul 2011 04:11:07 +0000 (-0400) Subject: Bluetooth: bnep: Fix lost wakeup of session thread X-Git-Tag: next-20110802~28^2~6 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=999e0498a3f56eba32aa5ef527f483110855b3a7;p=karo-tx-linux.git Bluetooth: bnep: Fix lost wakeup of session thread Fix race condition which can result in missing the wakeup intended to stop the session thread. Signed-off-by: Peter Hurley Signed-off-by: Gustavo F. Padovan --- diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index dfadb65012d2..eb8486fc4b83 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -484,9 +484,11 @@ static int bnep_session(void *arg) init_waitqueue_entry(&wait, current); add_wait_queue(sk_sleep(sk), &wait); - while (!kthread_should_stop()) { + while (1) { set_current_state(TASK_INTERRUPTIBLE); + if (kthread_should_stop()) + break; /* RX */ while ((skb = skb_dequeue(&sk->sk_receive_queue))) { skb_orphan(skb); @@ -507,7 +509,7 @@ static int bnep_session(void *arg) schedule(); } - set_current_state(TASK_RUNNING); + __set_current_state(TASK_RUNNING); remove_wait_queue(sk_sleep(sk), &wait); /* Cleanup session */