Linux bluetooth development
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: [RFC -v2 08/16] Bluetooth: Improving locking in l2cap_conn_start()
Date: Fri, 21 Dec 2012 16:10:51 -0200	[thread overview]
Message-ID: <1356113459-7932-9-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1356113459-7932-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Since we don't read bt_sk(sk) in here anymore we can remove the lock from
the block and only use it when calling l2cap_state_change().

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 4cc49f3..110a702 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1252,7 +1252,6 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
 			rsp.dcid = cpu_to_le16(chan->scid);
 
 			if (l2cap_chan_check_security(chan)) {
-				lock_sock(sk);
 				if (test_bit(CONN_DEFER_SETUP,
 					     &chan->conn_state)) {
 					rsp.result = __constant_cpu_to_le16(L2CAP_CR_PEND);
@@ -1260,11 +1259,10 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
 					chan->ops->defer(chan);
 
 				} else {
-					__l2cap_state_change(chan, BT_CONFIG);
+					l2cap_state_change(chan, BT_CONFIG);
 					rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS);
 					rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
 				}
-				release_sock(sk);
 			} else {
 				rsp.result = __constant_cpu_to_le16(L2CAP_CR_PEND);
 				rsp.status = __constant_cpu_to_le16(L2CAP_CS_AUTHEN_PEND);
@@ -6393,12 +6391,9 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 				__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
 			}
 		} else if (chan->state == BT_CONNECT2) {
-			struct sock *sk = chan->sk;
 			struct l2cap_conn_rsp rsp;
 			__u16 res, stat;
 
-			lock_sock(sk);
-
 			if (!status) {
 				if (test_bit(CONN_DEFER_SETUP,
 					     &chan->conn_state)) {
@@ -6406,19 +6401,17 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 					stat = L2CAP_CS_AUTHOR_PEND;
 					chan->ops->defer(chan);
 				} else {
-					__l2cap_state_change(chan, BT_CONFIG);
+					l2cap_state_change(chan, BT_CONFIG);
 					res = L2CAP_CR_SUCCESS;
 					stat = L2CAP_CS_NO_INFO;
 				}
 			} else {
-				__l2cap_state_change(chan, BT_DISCONN);
+				l2cap_state_change(chan, BT_DISCONN);
 				__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
 				res = L2CAP_CR_SEC_BLOCK;
 				stat = L2CAP_CS_NO_INFO;
 			}
 
-			release_sock(sk);
-
 			rsp.scid   = cpu_to_le16(chan->dcid);
 			rsp.dcid   = cpu_to_le16(chan->scid);
 			rsp.result = cpu_to_le16(res);
-- 
1.8.0.2


  parent reply	other threads:[~2012-12-21 18:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 18:10 [RFC -v2 00/16] Completely remove socket dependency from l2cap_core.c Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 01/16] Bluetooth: Add src and dst info to struct l2cap_chan Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 02/16] Bluetooth: Remove sk_sndtimeo from l2cap_core.c Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 03/16] Bluetooth: extend state_change() call to report errors too Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 04/16] Bluetooth: add l2cap_state_change_and_error() Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 05/16] Bluetooth: Add missing braces to an "else if" Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 06/16] Bluetooth: use l2cap_chan_ready() instead of duplicate code Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 07/16] Bluetooth: duplicate DEFER_SETUP flag on l2cap_chan Gustavo Padovan
2012-12-21 18:10 ` Gustavo Padovan [this message]
2012-12-21 18:10 ` [RFC -v2 09/16] Bluetooth: lock socket in defer_cb call Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 10/16] Bluetooth: Remove socket lock from state_change() in l2cap_core Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 11/16] Bluetooth: remove parent socket usage from l2cap_core.c Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 12/16] Bluetooth: Use abstract chan->data in comparison Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 13/16] Bluetooth: Move l2cap_wait_ack() to l2cap_sock.c Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 14/16] Bluetooth: Create l2cap->ops->resume() Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 15/16] Bluetooth: Create l2cap->ops->set_shutdown() Gustavo Padovan
2012-12-21 18:10 ` [RFC -v2 16/16] Bluetooth: Remove sk member from struct l2cap_chan Gustavo Padovan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1356113459-7932-9-git-send-email-gustavo@padovan.org \
    --to=gustavo@padovan.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox