Commit 3a39b782 authored by Jacob Siverskog's avatar Jacob Siverskog Committed by Christopher Friedt
Browse files

bluetooth: host: avoid freeing structure that's part of a linked list

see https://github.com/zephyrproject-rtos/zephyr/pull/39507

 for
context.
Signed-off-by: default avatarJacob Siverskog <jacob@teenage.engineering>
parent 9247efab
Showing with 6 additions and 2 deletions
+6 -2
......@@ -2518,7 +2518,6 @@ struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op, size_t len)
static void att_reset(struct bt_att *att)
{
struct bt_att_req *req, *tmp;
struct net_buf *buf;
#if CONFIG_BT_ATT_PREPARE_COUNT > 0
......@@ -2535,7 +2534,12 @@ static void att_reset(struct bt_att *att)
att->conn = NULL;
/* Notify pending requests */
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&att->reqs, req, tmp, node) {
while (!sys_slist_is_empty(&att->reqs)) {
struct bt_att_req *req;
sys_snode_t *node;
node = sys_slist_get_not_empty(&att->reqs);
req = CONTAINER_OF(node, struct bt_att_req, node);
if (req->func) {
req->func(NULL, BT_ATT_ERR_UNLIKELY, NULL, 0,
req->user_data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment