Skip to content

Commit 8a7889c

Browse files
jhedbergholtmann
authored andcommitted
Bluetooth: L2CAP: Fix returning correct LE CoC response codes
The core spec defines specific response codes for situations when the received CID is incorrect. Add the defines for these and return them as appropriate from the LE Connect Request handler function. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 2ab216a commit 8a7889c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ struct l2cap_conn_rsp {
275275
#define L2CAP_CR_AUTHORIZATION 0x0006
276276
#define L2CAP_CR_BAD_KEY_SIZE 0x0007
277277
#define L2CAP_CR_ENCRYPTION 0x0008
278+
#define L2CAP_CR_INVALID_SCID 0x0009
279+
#define L2CAP_CR_SCID_IN_USE 0x0010
278280

279281
/* connect/create channel status */
280282
#define L2CAP_CS_NO_INFO 0x0000

‎net/bluetooth/l2cap_core.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5437,9 +5437,16 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
54375437
goto response_unlock;
54385438
}
54395439

5440+
/* Check for valid dynamic CID range */
5441+
if (scid < L2CAP_CID_DYN_START || scid > L2CAP_CID_LE_DYN_END) {
5442+
result = L2CAP_CR_INVALID_SCID;
5443+
chan = NULL;
5444+
goto response_unlock;
5445+
}
5446+
54405447
/* Check if we already have channel with that dcid */
54415448
if (__l2cap_get_chan_by_dcid(conn, scid)) {
5442-
result = L2CAP_CR_NO_MEM;
5449+
result = L2CAP_CR_SCID_IN_USE;
54435450
chan = NULL;
54445451
goto response_unlock;
54455452
}

0 commit comments

Comments
 (0)