Skip to content

Commit 7718e6e

Browse files
MarekPietarlubos
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 ae06abb commit 7718e6e

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
@@ -695,13 +695,17 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf,
695695

696696
uint16_t frag_len = MIN(conn_mtu(conn), len);
697697

698-
if (buf->ref > 1 + (cb ? 1 : 0)) {
699-
/* Allow for an additional buffer reference if callback is provided.
700-
* This can be used to extend lifetime of the net buffer until the
701-
* data transmission is confirmed by ACK of the remote.
702-
*/
703-
__ASSERT_NO_MSG(false);
704-
}
698+
/* If ATT sent callback is delayed until data transmission is done by BLE controller, the
699+
* transmitted buffer may have an additional reference. The reference is used to extend
700+
* lifetime of the net buffer until the data transmission is confirmed by ACK of the remote.
701+
*
702+
* send_buf function can be called multiple times, if buffer has to be fragmented over HCI.
703+
* In that case, the callback is provided as an argument only for the last transmitted
704+
* fragment. The `buf->ref == 1` check is skipped because it's impossible to properly
705+
* validate number of references for the sent fragments if buffers may have the additional
706+
* reference.
707+
*/
708+
__ASSERT_NO_MSG(IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) || (buf->ref == 1));
705709

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

0 commit comments

Comments
 (0)