Skip to content

Commit 45ff5af

Browse files
lylezhu2012jhedberg
authored andcommitted
Bluetooth: Host: Check conn/channel status of L2CAP BR
For BR/EDR L2CAP, if the function bt_l2cap_br_chan_send_cb instead of bt_l2cap_chan_send is called, the ACL conn and L2CAP chennel status will not be checked. Check conn/channel status before sending data in function bt_l2cap_br_chan_send_cb. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 73bdf62 commit 45ff5af

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

subsys/bluetooth/host/classic/l2cap_br.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,23 @@ static void l2cap_br_conn_rsp(struct bt_l2cap_br *l2cap, uint8_t ident,
14691469
int bt_l2cap_br_chan_send_cb(struct bt_l2cap_chan *chan, struct net_buf *buf, bt_conn_tx_cb_t cb,
14701470
void *user_data)
14711471
{
1472-
struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan);
1472+
struct bt_l2cap_br_chan *br_chan;
1473+
1474+
if (!buf || !chan) {
1475+
return -EINVAL;
1476+
}
1477+
1478+
br_chan = BR_CHAN(chan);
1479+
1480+
LOG_DBG("chan %p buf %p len %zu", chan, buf, net_buf_frags_len(buf));
1481+
1482+
if (!chan->conn || chan->conn->state != BT_CONN_CONNECTED) {
1483+
return -ENOTCONN;
1484+
}
1485+
1486+
if (atomic_test_bit(chan->status, BT_L2CAP_STATUS_SHUTDOWN)) {
1487+
return -ESHUTDOWN;
1488+
}
14731489

14741490
if (buf->len > br_chan->tx.mtu) {
14751491
return -EMSGSIZE;

0 commit comments

Comments
 (0)