Skip to content

Commit

Permalink
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…padovan/bluetooth-2.6
  • Loading branch information
linvjw committed Jul 5, 2011
2 parents a0b8de3 + 163f4da commit f2529c2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ int hci_conn_del(struct hci_conn *conn)

hci_dev_put(hdev);

if (conn->handle == 0)
kfree(conn);

return 0;
}

Expand Down
18 changes: 11 additions & 7 deletions net/bluetooth/hidp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ static void hidp_idle_timeout(unsigned long arg)
{
struct hidp_session *session = (struct hidp_session *) arg;

kthread_stop(session->task);
atomic_inc(&session->terminate);
wake_up_process(session->task);
}

static void hidp_set_timer(struct hidp_session *session)
Expand Down Expand Up @@ -535,7 +536,8 @@ static void hidp_process_hid_control(struct hidp_session *session,
skb_queue_purge(&session->ctrl_transmit);
skb_queue_purge(&session->intr_transmit);

kthread_stop(session->task);
atomic_inc(&session->terminate);
wake_up_process(current);
}
}

Expand Down Expand Up @@ -706,9 +708,8 @@ static int hidp_session(void *arg)
add_wait_queue(sk_sleep(intr_sk), &intr_wait);
session->waiting_for_startup = 0;
wake_up_interruptible(&session->startup_queue);
while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);

set_current_state(TASK_INTERRUPTIBLE);
while (!atomic_read(&session->terminate)) {
if (ctrl_sk->sk_state != BT_CONNECTED ||
intr_sk->sk_state != BT_CONNECTED)
break;
Expand All @@ -726,6 +727,7 @@ static int hidp_session(void *arg)
hidp_process_transmit(session);

schedule();
set_current_state(TASK_INTERRUPTIBLE);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(intr_sk), &intr_wait);
Expand Down Expand Up @@ -1060,7 +1062,8 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
err_add_device:
hid_destroy_device(session->hid);
session->hid = NULL;
kthread_stop(session->task);
atomic_inc(&session->terminate);
wake_up_process(session->task);

unlink:
hidp_del_timer(session);
Expand Down Expand Up @@ -1111,7 +1114,8 @@ int hidp_del_connection(struct hidp_conndel_req *req)
skb_queue_purge(&session->ctrl_transmit);
skb_queue_purge(&session->intr_transmit);

kthread_stop(session->task);
atomic_inc(&session->terminate);
wake_up_process(session->task);
}
} else
err = -ENOENT;
Expand Down
1 change: 1 addition & 0 deletions net/bluetooth/hidp/hidp.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct hidp_session {
uint ctrl_mtu;
uint intr_mtu;

atomic_t terminate;
struct task_struct *task;

unsigned char keys[8];
Expand Down
5 changes: 3 additions & 2 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr

sk = chan->sk;

if (sk->sk_state != BT_CONFIG) {
if ((bt_sk(sk)->defer_setup && sk->sk_state != BT_CONNECT2) ||
(!bt_sk(sk)->defer_setup && sk->sk_state != BT_CONFIG)) {
struct l2cap_cmd_rej rej;

rej.reason = cpu_to_le16(0x0002);
Expand All @@ -2334,7 +2335,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr

/* Reject if config buffer is too small. */
len = cmd_len - sizeof(*req);
if (chan->conf_len + len > sizeof(chan->conf_req)) {
if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) {
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
l2cap_build_conf_rsp(chan, rsp,
L2CAP_CONF_REJECT, flags), rsp);
Expand Down

0 comments on commit f2529c2

Please sign in to comment.