diff options
-rw-r--r-- | net/bluetooth/bnep/bnep.h | 2 | ||||
-rw-r--r-- | net/bluetooth/bnep/core.c | 21 |
2 files changed, 9 insertions, 14 deletions
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h index d768e0434ed8..8e6c06158f8e 100644 --- a/net/bluetooth/bnep/bnep.h +++ b/net/bluetooth/bnep/bnep.h | |||
@@ -155,7 +155,7 @@ struct bnep_session { | |||
155 | unsigned int role; | 155 | unsigned int role; |
156 | unsigned long state; | 156 | unsigned long state; |
157 | unsigned long flags; | 157 | unsigned long flags; |
158 | atomic_t killed; | 158 | struct task_struct *task; |
159 | 159 | ||
160 | struct ethhdr eh; | 160 | struct ethhdr eh; |
161 | struct msghdr msg; | 161 | struct msghdr msg; |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 0a2e76bde542..ca39fcf010ce 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/net.h> | 37 | #include <linux/net.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/kthread.h> | ||
39 | #include <net/sock.h> | 40 | #include <net/sock.h> |
40 | 41 | ||
41 | #include <linux/socket.h> | 42 | #include <linux/socket.h> |
@@ -479,12 +480,11 @@ static int bnep_session(void *arg) | |||
479 | 480 | ||
480 | BT_DBG(""); | 481 | BT_DBG(""); |
481 | 482 | ||
482 | daemonize("kbnepd %s", dev->name); | ||
483 | set_user_nice(current, -15); | 483 | set_user_nice(current, -15); |
484 | 484 | ||
485 | init_waitqueue_entry(&wait, current); | 485 | init_waitqueue_entry(&wait, current); |
486 | add_wait_queue(sk_sleep(sk), &wait); | 486 | add_wait_queue(sk_sleep(sk), &wait); |
487 | while (!atomic_read(&s->killed)) { | 487 | while (!kthread_should_stop()) { |
488 | set_current_state(TASK_INTERRUPTIBLE); | 488 | set_current_state(TASK_INTERRUPTIBLE); |
489 | 489 | ||
490 | /* RX */ | 490 | /* RX */ |
@@ -611,11 +611,12 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) | |||
611 | 611 | ||
612 | __bnep_link_session(s); | 612 | __bnep_link_session(s); |
613 | 613 | ||
614 | err = kernel_thread(bnep_session, s, CLONE_KERNEL); | 614 | s->task = kthread_run(bnep_session, s, "kbnepd %s", dev->name); |
615 | if (err < 0) { | 615 | if (IS_ERR(s->task)) { |
616 | /* Session thread start failed, gotta cleanup. */ | 616 | /* Session thread start failed, gotta cleanup. */ |
617 | unregister_netdev(dev); | 617 | unregister_netdev(dev); |
618 | __bnep_unlink_session(s); | 618 | __bnep_unlink_session(s); |
619 | err = PTR_ERR(s->task); | ||
619 | goto failed; | 620 | goto failed; |
620 | } | 621 | } |
621 | 622 | ||
@@ -639,15 +640,9 @@ int bnep_del_connection(struct bnep_conndel_req *req) | |||
639 | down_read(&bnep_session_sem); | 640 | down_read(&bnep_session_sem); |
640 | 641 | ||
641 | s = __bnep_get_session(req->dst); | 642 | s = __bnep_get_session(req->dst); |
642 | if (s) { | 643 | if (s) |
643 | /* Wakeup user-space which is polling for socket errors. | 644 | kthread_stop(s->task); |
644 | * This is temporary hack until we have shutdown in L2CAP */ | 645 | else |
645 | s->sock->sk->sk_err = EUNATCH; | ||
646 | |||
647 | /* Kill session thread */ | ||
648 | atomic_inc(&s->killed); | ||
649 | wake_up_interruptible(sk_sleep(s->sock->sk)); | ||
650 | } else | ||
651 | err = -ENOENT; | 646 | err = -ENOENT; |
652 | 647 | ||
653 | up_read(&bnep_session_sem); | 648 | up_read(&bnep_session_sem); |