Skip to content

Commit b07b1bb

Browse files
HaavardReinordicjm
authored andcommitted
[nrf fromtree] 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]> (cherry picked from commit 2b42a1d) Signed-off-by: Håvard Reierstad <[email protected]>
1 parent 01ec0ff commit b07b1bb

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
@@ -2158,6 +2158,17 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident,
21582158
cid = sys_le16_to_cpu(ev->cid);
21592159
credits = sys_le16_to_cpu(ev->credits);
21602160

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

21632174
chan = bt_l2cap_le_lookup_tx_cid(conn, cid);

0 commit comments

Comments
 (0)