summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_core.c
diff options
context:
space:
mode:
authorJohan Hedberg2013-04-29 18:35:38 +0200
committerGustavo Padovan2013-06-23 01:23:48 +0200
commit9f22398ce4baf816535415e65949d03f55a7973a (patch)
tree2b7dad90909ec81acb41134b89f525e4d25e80b3 /net/bluetooth/l2cap_core.c
parentBluetooth: Fix EBUSY condition test in l2cap_chan_connect (diff)
downloadkernel-qcow2-linux-9f22398ce4baf816535415e65949d03f55a7973a.tar.gz
kernel-qcow2-linux-9f22398ce4baf816535415e65949d03f55a7973a.tar.xz
kernel-qcow2-linux-9f22398ce4baf816535415e65949d03f55a7973a.zip
Bluetooth: Fix hardcoding ATT CID in __l2cap_chan_add()
Since in the future more than the ATT CID may be permissible we should not be hardcoding it for all LE connections in __l2cap_chan_add(). Instead, the source ATT CID should only be set if the destination is also ATT, and in other cases we should just use the existing dynamic CID allocation function. Assigning scid based on dcid means that whenever __l2cap_chan_add() is called that chan->dcid is properly initialized. l2cap_le_conn_ready() wasn't initializing is properly so this is also taken care of in this patch. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r--net/bluetooth/l2cap_core.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 640423b4f411..4803610187ed 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -504,8 +504,10 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
if (conn->hcon->type == LE_LINK) {
/* LE connection */
chan->omtu = L2CAP_DEFAULT_MTU;
- chan->scid = L2CAP_CID_ATT;
- chan->dcid = L2CAP_CID_ATT;
+ if (chan->dcid == L2CAP_CID_ATT)
+ chan->scid = L2CAP_CID_ATT;
+ else
+ chan->scid = l2cap_alloc_cid(conn);
} else {
/* Alloc CID for connection-oriented socket */
chan->scid = l2cap_alloc_cid(conn);
@@ -1357,6 +1359,8 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
if (!chan)
goto clean;
+ chan->dcid = L2CAP_CID_ATT;
+
sk = chan->sk;
hci_conn_hold(conn->hcon);