Skip to content

Commit 4f64a3a

Browse files
MarekPietanordicjm
authored andcommitted
[nrf noup] bluetooth: conn: Skip buffer ref count check in send_buf
If ATT sent callback is delayed until data transmission is done by BLE controller, the transmitted buffer may have an additional reference. The reference is used to extend lifetime of the net buffer until the data transmission is confirmed by ACK of the remote. send_buf function can be called multiple times, if buffer has to be fragmented over HCI. In that case, the callback is provided as an argument only for the last transmitted fragment. The `buf->ref == 1` check is skipped because it's impossible to properly validate number of references for the sent fragments if buffers may have the additional reference. Jira: NCSDK-28624 Signed-off-by: Marek Pieta <[email protected]>
1 parent 5708d4e commit 4f64a3a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,17 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf,
654654

655655
uint16_t frag_len = MIN(conn_mtu(conn), len);
656656

657-
if (buf->ref > 1 + (cb ? 1 : 0)) {
658-
/* Allow for an additional buffer reference if callback is provided.
659-
* This can be used to extend lifetime of the net buffer until the
660-
* data transmission is confirmed by ACK of the remote.
661-
*/
662-
__ASSERT_NO_MSG(false);
663-
}
657+
/* If ATT sent callback is delayed until data transmission is done by BLE controller, the
658+
* transmitted buffer may have an additional reference. The reference is used to extend
659+
* lifetime of the net buffer until the data transmission is confirmed by ACK of the remote.
660+
*
661+
* send_buf function can be called multiple times, if buffer has to be fragmented over HCI.
662+
* In that case, the callback is provided as an argument only for the last transmitted
663+
* fragment. The `buf->ref == 1` check is skipped because it's impossible to properly
664+
* validate number of references for the sent fragments if buffers may have the additional
665+
* reference.
666+
*/
667+
__ASSERT_NO_MSG(IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) || (buf->ref == 1));
664668

665669
if (buf->len > frag_len) {
666670
LOG_DBG("keep %p around", buf);

0 commit comments

Comments
 (0)