From cd4b14feb1ac2c6cdbd5917ba0350fdd3a9a965a Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Mon, 21 Oct 2024 13:18:36 +0200 Subject: [PATCH] Revert "[nrf noup] bluetooth: conn: Allow for an extra ref in bt_l2cap_send_pdu" This reverts commit b0ce7fe23a0c83ce3038baf2b8899e0e6b1497fc. Signed-off-by: Pavel Vasilyev --- subsys/bluetooth/host/conn.c | 8 +------- subsys/bluetooth/host/l2cap.c | 8 ++------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index bd3933d5b56..bc3e43b73c2 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -695,13 +695,7 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf, uint16_t frag_len = MIN(conn_mtu(conn), len); - if (buf->ref > 1 + (cb ? 1 : 0)) { - /* Allow for an additional buffer reference if callback is provided. - * This can be used to extend lifetime of the net buffer until the - * data transmission is confirmed by ACK of the remote. - */ - __ASSERT_NO_MSG(false); - } + __ASSERT_NO_MSG(buf->ref == 1); if (buf->len > frag_len) { LOG_DBG("keep %p around", buf); diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 648e18183c4..b6ca2f3ea00 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -717,17 +717,13 @@ static void cancel_data_ready(struct bt_l2cap_le_chan *le_chan) int bt_l2cap_send_pdu(struct bt_l2cap_le_chan *le_chan, struct net_buf *pdu, bt_conn_tx_cb_t cb, void *user_data) { - /* Allow for an additional buffer reference if callback is provided. This can be used to - * extend lifetime of the net buffer until the data transmission is confirmed by ACK of the - * remote. - */ - if (pdu->ref > 1 + (cb ? 1 : 0)) { + if (pdu->ref != 1) { /* The host may alter the buf contents when fragmenting. Higher * layers cannot expect the buf contents to stay intact. Extra * refs suggests a silent data corruption would occur if not for * this error. */ - LOG_ERR("Expecting up to %d refs, got %d", cb ? 2 : 1, pdu->ref); + LOG_ERR("Expecting 1 ref, got %d", pdu->ref); return -EINVAL; }