Skip to content

Commit

Permalink
Bluetooth: L2CAP: Add missing req_mtu assert in l2cap_ecred_conn_req
Browse files Browse the repository at this point in the history
There is an assert that `req_psm` is the same for all channels in the
same connection request because HCI requires this. The same is true for
`req_mtu`. This adds the obviously missing assert.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
  • Loading branch information
alwa-nordic authored and carlescufi committed Apr 24, 2023
1 parent 3148389 commit 4664645
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions subsys/bluetooth/host/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ static int l2cap_ecred_conn_req(struct bt_l2cap_chan **chan, int channels)
int i;
uint8_t ident;
uint16_t req_psm;
uint16_t req_mtu;

if (!chan || !channels) {
return -EINVAL;
Expand All @@ -541,12 +542,15 @@ static int l2cap_ecred_conn_req(struct bt_l2cap_chan **chan, int channels)
req->mps = sys_cpu_to_le16(ch->rx.mps);
req->credits = sys_cpu_to_le16(ch->rx.init_credits);
req_psm = ch->psm;
req_mtu = ch->tx.mtu;

for (i = 0; i < channels; i++) {
ch = BT_L2CAP_LE_CHAN(chan[i]);

__ASSERT(ch->psm == req_psm,
"The PSM shall be the same for channels in the same request.");
__ASSERT(ch->tx.mtu == req_mtu,
"The MTU shall be the same for channels in the same request.");

ch->ident = ident;

Expand Down

0 comments on commit 4664645

Please sign in to comment.