Skip to content

Commit

Permalink
shared/bap: Properly cleanup bap remote endpoints
Browse files Browse the repository at this point in the history
When freeing a remote bap endpoint, the endpoint reference inside the
stream should be set to NULL, to avoid later use after free errors.
  • Loading branch information
iulia-tanasescu authored and Vudentz committed Feb 2, 2024
1 parent d14e0b5 commit 29dee7b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/shared/bap.c
Expand Up @@ -2984,6 +2984,16 @@ static void bap_state_free(void *data)
free(state);
}

static void bap_ep_free(void *data)
{
struct bt_bap_endpoint *ep = data;

if (ep && ep->stream)
ep->stream->ep = NULL;

free(ep);
}

static void bap_detached(void *data, void *user_data)
{
struct bt_bap_cb *cb = data;
Expand All @@ -3006,7 +3016,7 @@ static void bap_free(void *data)
queue_destroy(bap->ready_cbs, bap_ready_free);
queue_destroy(bap->state_cbs, bap_state_free);
queue_destroy(bap->local_eps, free);
queue_destroy(bap->remote_eps, free);
queue_destroy(bap->remote_eps, bap_ep_free);

queue_destroy(bap->reqs, bap_req_free);
queue_destroy(bap->notify, NULL);
Expand Down

0 comments on commit 29dee7b

Please sign in to comment.