Skip to content

Commit a58f407

Browse files
jori-nordicHuajiang Zheng
authored andcommitted
Bluetooth: L2CAP: Set NULL callback for PDUs
It was not being set, and thus if the user_data contained garbage from before, then conn.c would attempt to call that garbage. Static channels don't have this issue, as every "SDU" fits into one PDU. Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no> Co-authored-by: Huajiang Zheng <nxf88597@lsv051208.swis.nl-cdc01.nxp.com> (cherry picked from commit 1c65103)
1 parent fcc3a7e commit a58f407

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,16 @@ struct net_buf *l2cap_data_pull(struct bt_conn *conn,
938938
__maybe_unused struct net_buf *b = k_fifo_get(&lechan->tx_queue, K_NO_WAIT);
939939

940940
__ASSERT_NO_MSG(b == pdu);
941+
}
941942

942-
if (L2CAP_LE_CID_IS_DYN(lechan->tx.cid)) {
943-
LOG_DBG("adding `sdu_sent` callback");
944-
/* No user callbacks for SDUs */
945-
make_closure(pdu->user_data,
946-
l2cap_chan_sdu_sent,
947-
UINT_TO_POINTER(lechan->tx.cid));
948-
}
943+
if (last_frag && L2CAP_LE_CID_IS_DYN(lechan->tx.cid)) {
944+
bool sdu_end = last_frag && last_seg;
945+
946+
LOG_DBG("adding %s callback", sdu_end ? "`sdu_sent`" : "NULL");
947+
/* No user callbacks for SDUs */
948+
make_closure(pdu->user_data,
949+
sdu_end ? l2cap_chan_sdu_sent : NULL,
950+
sdu_end ? UINT_TO_POINTER(lechan->tx.cid) : NULL);
949951
}
950952

951953
if (last_frag) {

0 commit comments

Comments
 (0)