summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/bnep/core.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2011-08-05 10:41:35 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-08-11 19:50:27 -0300
commit751c10a56802513a6b057c8cf1552cecc1c9afde (patch)
tree958b4624a551577f68e0f0e357112637a10c520a /net/bluetooth/bnep/core.c
parent7bdb8a5cf17f66614a9897645efcd4ccc27535ee (diff)
downloadop-kernel-dev-751c10a56802513a6b057c8cf1552cecc1c9afde.zip
op-kernel-dev-751c10a56802513a6b057c8cf1552cecc1c9afde.tar.gz
Bluetooth: bnep: Fix deadlock in session deletion
Commit f4d7cd4a4c introduced the usage of kthread API. kthread_stop is a blocking function which returns only when the thread exits. In this case, the thread can't exit because it's waiting for the write lock, which is being held by bnep_del_connection() which is waiting for the thread to exit -- deadlock. Use atomic_t/wake_up_process instead to signal to the thread to exit. Signed-off-by: Jaikumar Ganesh <jaikumar@google.com> Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/bnep/core.c')
-rw-r--r--net/bluetooth/bnep/core.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 7e8ff3c..d9edfe8 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -487,7 +487,7 @@ static int bnep_session(void *arg)
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
- if (kthread_should_stop())
+ if (atomic_read(&s->terminate))
break;
/* RX */
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
@@ -642,9 +642,10 @@ int bnep_del_connection(struct bnep_conndel_req *req)
down_read(&bnep_session_sem);
s = __bnep_get_session(req->dst);
- if (s)
- kthread_stop(s->task);
- else
+ if (s) {
+ atomic_inc(&s->terminate);
+ wake_up_process(s->task);
+ } else
err = -ENOENT;
up_read(&bnep_session_sem);
OpenPOWER on IntegriCloud