Commit 550939e4 authored by Luiz Augusto von Dentz's avatar Luiz Augusto von Dentz Committed by Anas Nashif
Browse files

Bluetooth: L2CAP: Fix not including all DCIDs



The order of Destination CIDs shall correspond the order of Source CIDs
including its amount so errors that don't result in all connection being
refused shall not break the order of CIDs.

Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 56c712d2
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -1140,6 +1140,8 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
		goto response;
	}

	memset(dcid, 0, sizeof(dcid));

	while (buf->len >= sizeof(scid)) {
		scid = net_buf_pull_le16(buf);

@@ -1151,20 +1153,16 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident,
			dcid[i++] = sys_cpu_to_le16(ch->rx.cid);
			continue;
		/* Some connections refused – invalid Source CID */
		case BT_L2CAP_LE_ERR_INVALID_SCID:
		/* Some connections refused – Source CID already allocated */
		case BT_L2CAP_LE_ERR_SCID_IN_USE:
		/* Some connections refused – not enough resources
		 * available.
		 */
		default:
			/* If a Destination CID is 0x0000, the channel was not
			 * established.
			 */
			dcid[i++] = 0x0000;
			continue;
		/* Some connections refused – not enough resources
		 * available.
		 */
		case BT_L2CAP_LE_ERR_NO_RESOURCES:
		default:
			goto response;
		}
	}