2023-09-27 07:48:21

by Andrei Istodorescu

[permalink] [raw]
Subject: [PATCH BlueZ 2/2] shared/bap: Set stream lpac to NULL after removing the stream.

This is required as the pac is freed in another place and will result
in a dangling pointer.
---
src/shared/bap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 1c43680c2457..a0f0135eb135 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -2681,8 +2681,10 @@ static void remove_streams(void *data, void *user_data)
struct bt_bap_stream *stream;

stream = queue_remove_if(bap->streams, match_stream_lpac, pac);
- if (stream)
+ if (stream) {
+ stream->lpac = NULL; /* mark stream->lpac to NULL, as it will be freed in bt_bap_remove_pac */
bt_bap_stream_release(stream, NULL, NULL);
+ }
}

bool bt_bap_remove_pac(struct bt_bap_pac *pac)
--
2.39.2