]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Bluetooth: bnep: Fix lost wakeup of session thread
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 24 Jul 2011 04:11:07 +0000 (00:11 -0400)
committerGustavo F. Padovan <padovan@profusion.mobi>
Mon, 1 Aug 2011 17:55:53 +0000 (14:55 -0300)
Fix race condition which can result in missing the wakeup intended
to stop the session thread.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/bnep/core.c

index dfadb65012d2e19a81adef9a89618419bdacaa52..eb8486fc4b834e746d714dc7cd4804d85bf65921 100644 (file)
@@ -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 */