linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks.
@ 2009-08-24  3:45 Gustavo F. Padovan
  2009-08-24  3:45 ` [PATCH 2/2] Bluetooth: Use *_unaligned_le{16,32} Gustavo F. Padovan
  2009-12-14 10:36 ` [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks Andrei Emeltchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Gustavo F. Padovan @ 2009-08-24  3:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo

Avoid race conditions when acessing the sock.

Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
---
 net/bluetooth/l2cap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c04526f..efac637 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -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;
@@ -1203,6 +1204,7 @@ 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)
@@ -1210,6 +1212,7 @@ 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();
 
@@ -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)
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-15  8:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-24  3:45 [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks Gustavo F. Padovan
2009-08-24  3:45 ` [PATCH 2/2] Bluetooth: Use *_unaligned_le{16,32} Gustavo F. Padovan
2009-12-14 10:36 ` [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks Andrei Emeltchenko
2009-12-14 14:13   ` Gustavo F. Padovan
2009-12-14 17:53   ` Marcel Holtmann
2009-12-15  8:03     ` Andrei Emeltchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).