Skip to content

Commit 3a39b78

Browse files
jsiverskogcfriedt
authored andcommitted
bluetooth: host: avoid freeing structure that's part of a linked list
see #39507 for context. Signed-off-by: Jacob Siverskog <[email protected]>
1 parent 9247efa commit 3a39b78

File tree

1 file changed

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

1 file changed

+6
-2
lines changed

subsys/bluetooth/host/att.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,6 @@ struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
25182518

25192519
static void att_reset(struct bt_att *att)
25202520
{
2521-
struct bt_att_req *req, *tmp;
25222521
struct net_buf *buf;
25232522

25242523
#if CONFIG_BT_ATT_PREPARE_COUNT > 0
@@ -2535,7 +2534,12 @@ static void att_reset(struct bt_att *att)
25352534
att->conn = NULL;
25362535

25372536
/* Notify pending requests */
2538-
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&att->reqs, req, tmp, node) {
2537+
while (!sys_slist_is_empty(&att->reqs)) {
2538+
struct bt_att_req *req;
2539+
sys_snode_t *node;
2540+
2541+
node = sys_slist_get_not_empty(&att->reqs);
2542+
req = CONTAINER_OF(node, struct bt_att_req, node);
25392543
if (req->func) {
25402544
req->func(NULL, BT_ATT_ERR_UNLIKELY, NULL, 0,
25412545
req->user_data);

0 commit comments

Comments
 (0)