This is an automated email from the ASF dual-hosted git repository.
kopyscinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new b02b39bfb host/audio/ble_iso.c: fix deallocation of BIS
b02b39bfb is described below
commit b02b39bfb193a6bd9ffef3d6cab6b71712abd803
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Tue Apr 9 11:21:55 2024 +0200
host/audio/ble_iso.c: fix deallocation of BIS
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.
---
nimble/host/src/ble_iso.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/nimble/host/src/ble_iso.c b/nimble/host/src/ble_iso.c
index 004b1fc47..af728d135 100644
--- a/nimble/host/src/ble_iso.c
+++ b/nimble/host/src/ble_iso.c
@@ -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;
@@ -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;