Skip to contentSkip to conversation

Bluetooth: bnep: Fix lost wakeup of session thread

PATCH In review Peter Hurley 1 participant 1 message Jul 24, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/7 Bluetooth: bnep: Fix lost wakeup of session thread

Fix race condition which can result in missing the wakeup intended to stop the session thread.

---
 net/bluetooth/bnep/core.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/bnep/core.c +4 -2
index ca39fcf..7e8ff3c 100644
@@ -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);
@@ -504,7 +506,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 */
Signature · 1 line
1.7.4.1