Skip to content

Commit

Permalink
host/audio/ble_iso.c: fix deallocation of BIS
Browse files Browse the repository at this point in the history
Freeing memory back to BIS pool in loop while changing removing ISO
connections from list lead to memory leak. Now, memory is freed in
separate loop.
  • Loading branch information
KKopyscinski committed Apr 10, 2024
1 parent 0c6f2fe commit d2555dc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nimble/host/src/ble_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ static int
ble_iso_big_free(struct ble_iso_big *big)
{
struct ble_iso_conn *conn;
struct ble_iso_bis *rem_bis[MYNEWT_VAL(BLE_ISO_MAX_BISES)] = {
[0 ... MYNEWT_VAL(BLE_ISO_MAX_BISES) - 1] = NULL
};
uint8_t i = 0;

SLIST_FOREACH(conn, &ble_iso_conns, next) {
struct ble_iso_bis *bis;
Expand All @@ -216,10 +220,14 @@ ble_iso_big_free(struct ble_iso_big *big)
bis = CONTAINER_OF(conn, struct ble_iso_bis, conn);
if (bis->big == big) {
SLIST_REMOVE(&ble_iso_conns, conn, ble_iso_conn, next);
os_memblock_put(&ble_iso_bis_pool, bis);
rem_bis[i++] = bis;
}
}

while (i > 0) {
os_memblock_put(&ble_iso_bis_pool, rem_bis[--i]);
}

SLIST_REMOVE(&ble_iso_bigs, big, ble_iso_big, next);
os_memblock_put(&ble_iso_big_pool, big);
return 0;
Expand Down

0 comments on commit d2555dc

Please sign in to comment.