diff --git a/subsys/bluetooth/host/classic/l2cap_br.c b/subsys/bluetooth/host/classic/l2cap_br.c index 8413071d1b6f384..ab6dad5c3aa4fcf 100644 --- a/subsys/bluetooth/host/classic/l2cap_br.c +++ b/subsys/bluetooth/host/classic/l2cap_br.c @@ -869,9 +869,16 @@ int bt_l2cap_br_send_cb(struct bt_conn *conn, uint16_t cid, struct net_buf *buf, bt_conn_tx_cb_t cb, void *user_data) { struct bt_l2cap_chan *ch = bt_l2cap_br_lookup_tx_cid(conn, cid); - struct bt_l2cap_br_chan *br_chan = CONTAINER_OF(ch, struct bt_l2cap_br_chan, chan); + struct bt_l2cap_br_chan *br_chan; struct bt_l2cap_hdr *hdr; + if (ch == NULL) { + LOG_WRN("CID %d is not found on conn %p", cid, conn); + return -ESHUTDOWN; + } + + br_chan = CONTAINER_OF(ch, struct bt_l2cap_br_chan, chan); + LOG_DBG("chan %p buf %p len %zu", br_chan, buf, buf->len); #if L2CAP_BR_RET_FC_ENABLE