Skip to content

Commit 7bea193

Browse files
committed
[nrf noup] bluetooth: att: Fix CONFIG_BT_ATT_SENT_CB_AFTER_TX
The `delay ATT sent callback until data transmission is done by controller` feature introduces an extra `net_buf` reference which is removed on sent callback. Make sure to remove the reference on BLE disconnection to free the buffer as the registered sent callback will not be called. Jira: NCSDK-35650 Signed-off-by: Marek Pieta <[email protected]>
1 parent 69ad052 commit 7bea193

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ static void l2cap_chan_del(struct bt_l2cap_chan *chan)
274274
*/
275275
while ((buf = k_fifo_get(&le_chan->tx_queue, K_NO_WAIT))) {
276276
net_buf_unref(buf);
277+
/* The feature might introduce an additional net buffer reference. Remove it to free
278+
* the buffer as the registered sent callback will not be called.
279+
*/
280+
if (IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) && (buf->ref == 1)) {
281+
net_buf_unref(buf);
282+
}
277283
}
278284

279285
if (ops->disconnected) {

0 commit comments

Comments
 (0)