Skip to content

Commit

Permalink
Bluetooth: Add locking scheme to L2CAP timeout callbacks
Browse files Browse the repository at this point in the history
Avoid race conditions when accessing the L2CAP socket from within the
timeout handlers.

Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Gustavo F. Padovan authored and holtmann committed Aug 24, 2009
1 parent 9e726b1 commit e686219
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/bluetooth/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
struct sock *sk = (void *) arg;
u16 control;

bh_lock_sock(sk);
if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) {
l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk);
return;
Expand All @@ -1203,13 +1204,15 @@ static void l2cap_monitor_timeout(unsigned long arg)
control = L2CAP_CTRL_POLL;
control |= L2CAP_SUPER_RCV_READY;
l2cap_send_sframe(l2cap_pi(sk), control);
bh_unlock_sock(sk);
}

static void l2cap_retrans_timeout(unsigned long arg)
{
struct sock *sk = (void *) arg;
u16 control;

bh_lock_sock(sk);
l2cap_pi(sk)->retry_count = 1;
__mod_monitor_timer();

Expand All @@ -1218,6 +1221,7 @@ static void l2cap_retrans_timeout(unsigned long arg)
control = L2CAP_CTRL_POLL;
control |= L2CAP_SUPER_RCV_READY;
l2cap_send_sframe(l2cap_pi(sk), control);
bh_unlock_sock(sk);
}

static void l2cap_drop_acked_frames(struct sock *sk)
Expand Down

0 comments on commit e686219

Please sign in to comment.