Skip to content

Commit 2b42a1d

Browse files
HaavardReicfriedt
authored andcommitted
Bluetooth: Host: Add l2cap credit param checks
Adds a missing requirement from Core Spec V6.0 Vol 3.A chapters 10.1 and 10.2 to ignore L2CAP_FLOW_CONTROL_CREDIT_IND packets with the credit value set to 0. Matches existing credit-related functions by checking that the CID is in the dynamic range (you can't add credits to fixed channels). Signed-off-by: Håvard Reierstad <[email protected]>
1 parent 06bcb5a commit 2b42a1d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,17 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident,
21542154
cid = sys_le16_to_cpu(ev->cid);
21552155
credits = sys_le16_to_cpu(ev->credits);
21562156

2157+
if (!L2CAP_LE_CID_IS_DYN(cid)) {
2158+
LOG_WRN("Can't add credits to non-dynamic channel %p (cid 0x%04x)", &l2cap->chan,
2159+
cid);
2160+
return;
2161+
}
2162+
2163+
if (credits == 0U) {
2164+
LOG_WRN("Ignoring zero credit packet");
2165+
return;
2166+
}
2167+
21572168
LOG_DBG("cid 0x%04x credits %u", cid, credits);
21582169

21592170
chan = bt_l2cap_le_lookup_tx_cid(conn, cid);

0 commit comments

Comments
 (0)