Skip to content

Commit e4bcd6b

Browse files
donatiengcarlescufi
authored andcommitted
Bluetooth: Host: Check connection status before sending credits
Upon receiving a L2CAP PDU, only send credits back if the L2CAP channel hasn't been disconnected. The recv() callback called from l2cap_chan_le_recv() can trigger a disconnect, which would cause an assert failure when attempting to send credits back. Signed-off-by: Donatien Garnier <[email protected]>
1 parent 6783848 commit e4bcd6b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,12 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan,
26532653
return;
26542654
}
26552655

2656-
l2cap_chan_send_credits(chan, 1);
2656+
/* Only attempt to send credits if the channel wasn't disconnected
2657+
* in the recv() callback above
2658+
*/
2659+
if (bt_l2cap_chan_get_state(&chan->chan) == BT_L2CAP_CONNECTED) {
2660+
l2cap_chan_send_credits(chan, 1);
2661+
}
26572662
}
26582663

26592664
static void l2cap_chan_recv_queue(struct bt_l2cap_le_chan *chan,

0 commit comments

Comments
 (0)