Skip to content

Commit 8abd696

Browse files
VudentzAnas Nashif
authored andcommitted
Bluetooth: ATT: Fix using k_fifo API with net_buf
net_buf shall not be used with k_fifo since net_buf_unref will assume unused bytes in the beginning are actually fragments causing it to unref them as well. Jira: ZEP-1489 Change-Id: I5ce420de73b245dc20eb15ea4d8d0b6ba346e513 Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 598ef74 commit 8abd696

File tree

1 file changed

+7
-2
lines changed
  • subsys/bluetooth/host

1 file changed

+7
-2
lines changed

subsys/bluetooth/host/att.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,10 @@ static uint8_t att_prep_write_rsp(struct bt_att *att, uint16_t handle,
12791279
return 0;
12801280
}
12811281

1282+
BT_DBG("buf %p handle 0x%04x offset %u", data.buf, handle, offset);
1283+
12821284
/* Store buffer in the outstanding queue */
1283-
k_fifo_put(&att->prep_queue, data.buf);
1285+
net_buf_put(&att->prep_queue, data.buf);
12841286

12851287
/* Generate response */
12861288
data.buf = bt_att_create_pdu(conn, BT_ATT_OP_PREPARE_WRITE_RSP, 0);
@@ -1327,9 +1329,12 @@ static uint8_t att_exec_write_rsp(struct bt_att *att, uint8_t flags)
13271329
struct net_buf *buf;
13281330
uint8_t err = 0;
13291331

1330-
while ((buf = k_fifo_get(&att->prep_queue, K_NO_WAIT))) {
1332+
while ((buf = net_buf_get_timeout(&att->prep_queue, 0, K_NO_WAIT))) {
13311333
struct bt_attr_data *data = net_buf_user_data(buf);
13321334

1335+
BT_DBG("buf %p handle 0x%04x offset %u", buf, data->handle,
1336+
data->offset);
1337+
13331338
/* Just discard the data if an error was set */
13341339
if (!err && flags == BT_ATT_FLAG_EXEC) {
13351340
err = att_write_rsp(conn, BT_ATT_OP_EXEC_WRITE_REQ, 0,

0 commit comments

Comments
 (0)