* [PATCH BlueZ v3 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed
2026-11-24 15:09 [PATCH BlueZ v3 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
@ 2026-11-24 15:09 ` Simon Mikuda
2026-11-24 15:09 ` [PATCH BlueZ v3 3/4] bap: Don't leak the io of a PA sync that failed Simon Mikuda
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-24 15:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
bt_bap_remove_pac() did not find a broadcast sink PAC, which left the
PAC of an unregistered endpoint in use. Check in the teardown of every
test that registers one that its removal succeeds.
Assisted-by: Claude:claude-opus-5-5
---
unit/test-bap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/unit/test-bap.c b/unit/test-bap.c
index bfe98a885..9508c503e 100644
--- a/unit/test-bap.c
+++ b/unit/test-bap.c
@@ -1307,7 +1307,10 @@ static void test_teardown(const void *user_data)
bt_bap_remove_pac(data->snk);
bt_bap_remove_pac(data->src);
bt_bap_remove_pac(data->bsrc);
- bt_bap_remove_pac(data->bsnk);
+
+ if (data->bsnk)
+ g_assert(bt_bap_remove_pac(data->bsnk));
+
gatt_db_unref(data->db);
bt_gatt_server_unref(data->server);
data->server = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ v3 3/4] bap: Don't leak the io of a PA sync that failed
2026-11-24 15:09 [PATCH BlueZ v3 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
2026-11-24 15:09 ` [PATCH BlueZ v3 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed Simon Mikuda
@ 2026-11-24 15:09 ` Simon Mikuda
2026-11-24 15:09 ` [PATCH BlueZ v3 4/4] bap: Close a pending PA or BIG sync when a sink session ends Simon Mikuda
2026-11-24 20:52 ` [BlueZ,v3,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-24 15:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
From: Simon Mikuda <simon.mikuda@gmail.com>
The kernel reports a PA sync that times out twice.
iso_pa_sync_confirm_cb() replaced data->io_id for the second io, so the
watch of the first one stayed, holding the last reference of its io and
keeping the failed sync in the kernel. Where PA syncs are BIS
connections on BIG 0, a broadcast source on BIG 0 then fails to bind
with EADDRINUSE until bluetoothd restarts.
Remove the previous watch, which also closes its io.
Fixes: 2748c60a2c6b ("bap: Wait for BIG Info report event before creating streams")
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/bap.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 98ef26997..9a456f45b 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1912,6 +1912,13 @@ static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data)
* encryption flag is also available.
*/
DBG("PA Sync done");
+
+ /* A failed PA sync is reported twice. Dropping the previous watch also
+ * closes its io, as the watch holds the last reference.
+ */
+ if (data->io_id)
+ g_source_remove(data->io_id);
+
data->io_id = g_io_add_watch(io, G_IO_OUT, big_info_report_cb,
user_data);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH BlueZ v3 4/4] bap: Close a pending PA or BIG sync when a sink session ends
2026-11-24 15:09 [PATCH BlueZ v3 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
2026-11-24 15:09 ` [PATCH BlueZ v3 2/4] unit/test-bap: Check that a broadcast sink PAC can be removed Simon Mikuda
2026-11-24 15:09 ` [PATCH BlueZ v3 3/4] bap: Don't leak the io of a PA sync that failed Simon Mikuda
@ 2026-11-24 15:09 ` Simon Mikuda
2026-11-24 20:52 ` [BlueZ,v3,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: Simon Mikuda @ 2026-11-24 15:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda
bap_bcast_disconnect() frees the broadcast sink setups, but listen_io
stays open with a callback on one of them, and so does the watch of a
PA sync waiting for BIGInfo, which is on the accepted channel rather
than on listen_io. A PA or BIG sync that completes after the session
ended crashes bluetoothd:
#4 iso_do_big_sync (io=0xaaaad1ab3a30, user_data=0xaaaad1a87110)
at profiles/audio/bap.c:3689
#5 server_cb (io=0xaaaad1aabd30, cond=<optimized out>,
user_data=0xaaaad1ad1310) at btio/btio.c:285
Remove the watch and close listen_io before freeing the setups, and
release a PA sync kept for a stream to be enabled. iso_do_big_sync()
now clears io_id, so later cleanup does not remove an expired source.
Fixes: feb4ee9dcd4b ("bap: Fix use-after-free in broadcast sink cleanup")
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/bap.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 9a456f45b..eff621762 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -3957,6 +3957,8 @@ static gboolean iso_do_big_sync(GIOChannel *io, GIOCondition cond,
struct bt_iso_qos qos;
struct queue *links = bt_bap_stream_io_get_links(setup->stream);
+ data->io_id = 0;
+
DBG("BIG info received, do BIG sync");
if (data->listen_io != io) {
@@ -4294,6 +4296,24 @@ static int bap_bcast_disconnect(struct btd_service *service)
error("BAP service not handled by profile");
return -EINVAL;
}
+
+ /* A pending PA or BIG sync calls back with one of the setups freed
+ * below, and a PA sync kept for them is of no use any more: close
+ * both.
+ */
+ if (data->io_id) {
+ g_source_remove(data->io_id);
+ data->io_id = 0;
+ }
+
+ pa_sync_release(data);
+
+ if (data->listen_io) {
+ g_io_channel_shutdown(data->listen_io, TRUE, NULL);
+ g_io_channel_unref(data->listen_io);
+ data->listen_io = NULL;
+ }
+
/* Clean up broadcast sinks before detach (like unicast does) */
if (data->bcast_snks) {
bcast_snks = data->bcast_snks;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* RE: [BlueZ,v3,1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac()
2026-11-24 15:09 [PATCH BlueZ v3 1/4] shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac() Simon Mikuda
` (2 preceding siblings ...)
2026-11-24 15:09 ` [PATCH BlueZ v3 4/4] bap: Close a pending PA or BIG sync when a sink session ends Simon Mikuda
@ 2026-11-24 20:52 ` bluez.test.bot
3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-11-24 20:52 UTC (permalink / raw)
To: linux-bluetooth, simon.mikuda
[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1220993/
---Test result---
Test Summary:
CheckPatch PASS 1.27 seconds
GitLint PASS 0.92 seconds
BuildEll PASS 17.24 seconds
BluezMake PASS 238.56 seconds
MakeCheck PASS 13.51 seconds
MakeDistcheck PASS 119.38 seconds
CheckValgrind PASS 293.93 seconds
CheckSmatch WARNING 241.76 seconds
bluezmakeextell PASS 76.27 seconds
TestFunctional PASS 949.07 seconds
IncrementalBuild PASS 267.67 seconds
ScanBuild PASS 891.63 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
https://github.com/bluez/bluez/pull/2909
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread