[PATCH v14 1/2] Bluetooth: L2CAP: Restrict LE credits to connected CoCs

From: Kyle Pepper

Date: Wed Nov 25 2026 - 18:44:55 EST


Do not let credit indications change fixed channels or complete pending
connection setup. Validate the channel state and mode before accounting
credits, checking overflow or invoking its resume callback.

AI assistance: Codex prepared this attribution revision and assisted
with validation and commit text. Earlier revisions disclosed LLM
assistance for the credit-state guard.

Fixes: fad5fc89594d ("Bluetooth: Add LE flow control discipline")
Signed-off-by: Kyle Pepper <cochcoder@xxxxxxxxx>
---
Changes in v14:
- Replace the obsolete Assisted-by trailer with AI disclosure in each
commit message, following current kernel tool-generated content guidance.
- Rebase on current bluetooth-next; both patches' code is unchanged.

Previous v13 (no cover letter):
https://lore.kernel.org/linux-bluetooth/9d9d37680044266dbd1d6919b08564026afcd87d.1795528595.git.github.filter194@xxxxxxxxx/

V13 CI passed all 12 other jobs, including the kernel builds and
l2cap-tester. CheckPatch rejected the obsolete Assisted-by: LLM trailer.
Those are v13 results; v14 remote CI has not run.

net/bluetooth/l2cap_core.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 943effc867402e232d4d4c4a93d4b7ba5d376367..8229bddca5df761dd1359b88752e3d5f6d6090cf 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5469,6 +5469,11 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,

l2cap_chan_lock(chan);

+ if (chan->state != BT_CONNECTED ||
+ (chan->mode != L2CAP_MODE_LE_FLOWCTL &&
+ chan->mode != L2CAP_MODE_EXT_FLOWCTL))
+ goto unlock;
+
max_credits = LE_FLOWCTL_MAX_CREDITS - chan->tx_credits;
if (credits > max_credits) {
BT_ERR("LE credits overflow");

base-commit: f57f78086ab54f3b3122fbaeba2c842ba7bb6d00