From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This makes bt_bap_ref_safe check that bap instance is part of sessions list which means it is attached/valid. --- src/shared/bap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 4722ed1a1b27..804352db9c41 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -1033,7 +1033,7 @@ static void stream_notify_metadata(struct bt_bap_stream *stream) static struct bt_bap *bt_bap_ref_safe(struct bt_bap *bap) { - if (!bap || !bap->ref_count) + if (!bap || !bap->ref_count || !queue_find(sessions, NULL, bap)) return NULL; return bt_bap_ref(bap); -- 2.43.0