aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bluetooth/l2cap_core.c21
-rw-r--r--net/bluetooth/l2cap_sock.c9
2 files changed, 18 insertions, 12 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index cd28057d2903..e5c5c7427c41 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -498,18 +498,10 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
498 498
499 switch (chan->chan_type) { 499 switch (chan->chan_type) {
500 case L2CAP_CHAN_CONN_ORIENTED: 500 case L2CAP_CHAN_CONN_ORIENTED:
501 if (conn->hcon->type == LE_LINK) { 501 /* Alloc CID for connection-oriented socket */
502 if (chan->dcid == L2CAP_CID_ATT) { 502 chan->scid = l2cap_alloc_cid(conn);
503 chan->omtu = L2CAP_DEFAULT_MTU; 503 if (conn->hcon->type == ACL_LINK)
504 chan->scid = L2CAP_CID_ATT;
505 } else {
506 chan->scid = l2cap_alloc_cid(conn);
507 }
508 } else {
509 /* Alloc CID for connection-oriented socket */
510 chan->scid = l2cap_alloc_cid(conn);
511 chan->omtu = L2CAP_DEFAULT_MTU; 504 chan->omtu = L2CAP_DEFAULT_MTU;
512 }
513 break; 505 break;
514 506
515 case L2CAP_CHAN_CONN_LESS: 507 case L2CAP_CHAN_CONN_LESS:
@@ -7025,7 +7017,12 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7025 goto done; 7017 goto done;
7026 } 7018 }
7027 7019
7028 if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && !(psm || cid)) { 7020 if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && !psm) {
7021 err = -EINVAL;
7022 goto done;
7023 }
7024
7025 if (chan->chan_type == L2CAP_CHAN_FIXED && !cid) {
7029 err = -EINVAL; 7026 err = -EINVAL;
7030 goto done; 7027 goto done;
7031 } 7028 }
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index fe086b4efc0c..04abd26a3466 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -101,6 +101,15 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
101 if (!bdaddr_type_is_valid(la.l2_bdaddr_type)) 101 if (!bdaddr_type_is_valid(la.l2_bdaddr_type))
102 return -EINVAL; 102 return -EINVAL;
103 103
104 if (la.l2_cid) {
105 /* When the socket gets created it defaults to
106 * CHAN_CONN_ORIENTED, so we need to overwrite the
107 * default here.
108 */
109 chan->chan_type = L2CAP_CHAN_FIXED;
110 chan->omtu = L2CAP_DEFAULT_MTU;
111 }
112
104 if (bdaddr_type_is_le(la.l2_bdaddr_type)) { 113 if (bdaddr_type_is_le(la.l2_bdaddr_type)) {
105 if (!enable_lecoc && la.l2_psm) 114 if (!enable_lecoc && la.l2_psm)
106 return -EINVAL; 115 return -EINVAL;