linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Check for chan_type before locking sk
@ 2012-01-20 14:35 Emeltchenko Andrei
  2012-01-21 16:40 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Emeltchenko Andrei @ 2012-01-20 14:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Removes un-needed locking/unlocking if chan_type is not
L2CAP_CHAN_CONN_ORIENTED and also protects from locking
zero sk.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_core.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b303eae..916ddb1 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -770,13 +770,12 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
 	list_for_each_entry_rcu(chan, &conn->chan_l, list) {
 		struct sock *sk = chan->sk;
 
-		bh_lock_sock(sk);
-
 		if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
-			bh_unlock_sock(sk);
 			continue;
 		}
 
+		bh_lock_sock(sk);
+
 		if (chan->state == BT_CONNECT) {
 			struct l2cap_conn_req req;
 
-- 
1.7.4.1


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

* Re: [PATCH] Bluetooth: Check for chan_type before locking sk
  2012-01-20 14:35 [PATCH] Bluetooth: Check for chan_type before locking sk Emeltchenko Andrei
@ 2012-01-21 16:40 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2012-01-21 16:40 UTC (permalink / raw)
  To: Emeltchenko Andrei; +Cc: linux-bluetooth

Hi Andrei,

> Removes un-needed locking/unlocking if chan_type is not
> L2CAP_CHAN_CONN_ORIENTED and also protects from locking
> zero sk.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/l2cap_core.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index b303eae..916ddb1 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -770,13 +770,12 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
>  	list_for_each_entry_rcu(chan, &conn->chan_l, list) {
>  		struct sock *sk = chan->sk;
>  
> -		bh_lock_sock(sk);
> -
>  		if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
> -			bh_unlock_sock(sk);
>  			continue;
>  		}

this actually raises the question how l2cap_chan is protected. Seems
like we are using the socket lock to protect it. Maybe that needs to be
untangled first.

Regards

Marcel



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

end of thread, other threads:[~2012-01-21 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20 14:35 [PATCH] Bluetooth: Check for chan_type before locking sk Emeltchenko Andrei
2012-01-21 16:40 ` Marcel Holtmann

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).