Skip to content

Commit

Permalink
Bluetooth: Fix double locking in LE and conless chan
Browse files Browse the repository at this point in the history
Remove socket lock since chan->ops->recv locks socket itself.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
Andrei Emeltchenko authored and Johan Hedberg committed Feb 24, 2012
1 parent 8a7a3fd commit 5b4ceda
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4369,18 +4369,13 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk

static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, struct sk_buff *skb)
{
struct sock *sk = NULL;
struct l2cap_chan *chan;

chan = l2cap_global_chan_by_psm(0, psm, conn->src);
if (!chan)
goto drop;

sk = chan->sk;

lock_sock(sk);

BT_DBG("sk %p, len %d", sk, skb->len);
BT_DBG("chan %p, len %d", chan, skb->len);

if (chan->state != BT_BOUND && chan->state != BT_CONNECTED)
goto drop;
Expand All @@ -4389,31 +4384,23 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
goto drop;

if (!chan->ops->recv(chan->data, skb))
goto done;
return 0;

drop:
kfree_skb(skb);

done:
if (sk)
release_sock(sk);
return 0;
}

static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct sk_buff *skb)
{
struct sock *sk = NULL;
struct l2cap_chan *chan;

chan = l2cap_global_chan_by_scid(0, cid, conn->src);
if (!chan)
goto drop;

sk = chan->sk;

lock_sock(sk);

BT_DBG("sk %p, len %d", sk, skb->len);
BT_DBG("chan %p, len %d", chan, skb->len);

if (chan->state != BT_BOUND && chan->state != BT_CONNECTED)
goto drop;
Expand All @@ -4422,14 +4409,11 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
goto drop;

if (!chan->ops->recv(chan->data, skb))
goto done;
return 0;

drop:
kfree_skb(skb);

done:
if (sk)
release_sock(sk);
return 0;
}

Expand Down

0 comments on commit 5b4ceda

Please sign in to comment.