diff mbox series

[BlueZ,v3,3/3] shared/bap: Make bt_bap_ref_safe check if the instance is attached

Message ID 20240206223513.2783330-3-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v3,1/3] shared/bap: Rework stream procedures | expand

Commit Message

Luiz Augusto von Dentz Feb. 6, 2024, 10:35 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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 mbox series

Patch

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);