summaryrefslogtreecommitdiff
path: root/net/bluetooth/cmtp
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-08-29 13:38:29 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-29 13:38:29 -0700
commit0f43dd546d991ca260d8a72d07f617907c508de8 (patch)
tree65142f2e3a03ce712c76a45f41c94e2d833e08f7 /net/bluetooth/cmtp
parent2cd6c7f7f1e3a116506bb3326f0d23a6b801638a (diff)
parente9278a475f845833b569ca47171e64fe48c616e0 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (42 commits) netpoll: fix incorrect access to skb data in __netpoll_rx cassini: init before use in cas_interruptN. can: ti_hecc: Fix uninitialized spinlock in probe can: ti_hecc: Fix unintialized variable net: sh_eth: fix the compile error net/phy: fix DP83865 phy interrupt handler sendmmsg/sendmsg: fix unsafe user pointer access ibmveth: Fix leak when recycling skb and hypervisor returns error arp: fix rcu lockdep splat in arp_process() bridge: fix a possible use after free bridge: Pseudo-header required for the checksum of ICMPv6 mcast: Fix source address selection for multicast listener report MAINTAINERS: Update GIT trees for network development ath9k: Fix PS wrappers in ath9k_set_coverage_class carl9170: Fix mismatch in carl9170_op_set_key mutex lock-unlock wl12xx: add max_sched_scan_ssids value to the hw description wl12xx: Fix validation of pm_runtime_get_sync return value wl12xx: Remove obsolete testmode NVS push command bcma: add uevent to the bus, to autoload drivers ath9k_hw: Fix STA (AR9485) bringup issue due to incorrect MAC address ...
Diffstat (limited to 'net/bluetooth/cmtp')
-rw-r--r--net/bluetooth/cmtp/capi.c3
-rw-r--r--net/bluetooth/cmtp/cmtp.h1
-rw-r--r--net/bluetooth/cmtp/core.c20
3 files changed, 15 insertions, 9 deletions
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 040f67b12978..50f0d135eb8f 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -386,7 +386,8 @@ static void cmtp_reset_ctr(struct capi_ctr *ctrl)
capi_ctr_down(ctrl);
- kthread_stop(session->task);
+ atomic_inc(&session->terminate);
+ wake_up_process(session->task);
}
static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp)
diff --git a/net/bluetooth/cmtp/cmtp.h b/net/bluetooth/cmtp/cmtp.h
index db43b54ac9af..c32638dddbf9 100644
--- a/net/bluetooth/cmtp/cmtp.h
+++ b/net/bluetooth/cmtp/cmtp.h
@@ -81,6 +81,7 @@ struct cmtp_session {
char name[BTNAMSIZ];
+ atomic_t terminate;
struct task_struct *task;
wait_queue_head_t wait;
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index c5b11af908be..521baa4fe835 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -292,9 +292,11 @@ static int cmtp_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 (atomic_read(&session->terminate))
+ break;
if (sk->sk_state != BT_CONNECTED)
break;
@@ -307,7 +309,7 @@ static int cmtp_session(void *arg)
schedule();
}
- set_current_state(TASK_RUNNING);
+ __set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);
down_write(&cmtp_session_sem);
@@ -380,16 +382,17 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
if (!(session->flags & (1 << CMTP_LOOPBACK))) {
err = cmtp_attach_device(session);
- if (err < 0)
- goto detach;
+ if (err < 0) {
+ atomic_inc(&session->terminate);
+ wake_up_process(session->task);
+ up_write(&cmtp_session_sem);
+ return err;
+ }
}
up_write(&cmtp_session_sem);
return 0;
-detach:
- cmtp_detach_device(session);
-
unlink:
__cmtp_unlink_session(session);
@@ -414,7 +417,8 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
skb_queue_purge(&session->transmit);
/* Stop session thread */
- kthread_stop(session->task);
+ atomic_inc(&session->terminate);
+ wake_up_process(session->task);
} else
err = -ENOENT;