shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac()
PATCH v2 1/4 shared/bap: Remove broadcast sink PACs in bt_bap_remove_pac()
bt_bap_remove_pac() looked for the PAC in the sink, source and broadcast source lists only, so a broadcast sink PAC stayed in broadcast_sinks after its endpoint was freed. When the endpoint owner goes away, like WirePlumber restarting, the next BIGInfo matches the stale PAC and bluetoothd crashes:
pac_bcast_config (endpoint=<freed>) at profiles/audio/media.c pac_config () at profiles/audio/media.c bap_bcast_config () at src/shared/bap.c bt_bap_stream_config () at src/shared/bap.c create_stream_for_bis () at profiles/audio/bap.c bis_handler () at profiles/audio/bap.c bt_bap_parse_base () at src/shared/bap.c big_info_report_cb () at profiles/audio/bap.c
--- src/shared/bap.c | 3 +++ 1 file changed, 3 insertions(+)
src/shared/bap.c +3 -0
@@ -4864,6 +4864,9 @@ bool bt_bap_remove_pac(struct bt_bap_pac *pac)if (queue_remove_if (pac->bdb->broadcast_sources,NULL , pac)) goto found; +if (queue_remove_if (pac->bdb->broadcast_sinks,NULL , pac)) + goto found; +return false; found:
base-commit: 1adfe662efeff12997df9ddd0960dbd0de9c8ea7
Signature · 1 line
2.43.0
PATCH v2 2/4 unit/test-bap: Check that a broadcast sink PAC can be removed
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.
--- unit/test-bap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
unit/test-bap.c +4 -1
@@ -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 ;
Signature · 1 line
2.43.0
PATCH v2 3/4 bap: Don't leak the io of a PA sync that failed
In reply to Simon MikudaFrom: Simon Mikuda <[email protected]>
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.
--- profiles/audio/bap.c | 7 +++++++ 1 file changed, 7 insertions(+)
profiles/audio/bap.c +7 -0
@@ -1896,6 +1896,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); }
Signature · 1 line
2.43.0
PATCH v2 4/4 bap: Close a pending PA or BIG sync when a sink session ends
In reply to Simon Mikudabap_bcast_disconnect() frees the broadcast sink setups, but listen_io stays open with a callback on one of them. A PA 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:285Close listen_io before freeing the setups.
--- profiles/audio/bap.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
profiles/audio/bap.c +10 -0
@@ -4284,6 +4284,16 @@ 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, close it. +*/ +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;
Signature · 1 line
2.43.0
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/1218934/
---Test result---
Test Summary:
CheckPatch PASS 0.89 seconds GitLint PASS 0.67 seconds BuildEll PASS 13.71 seconds BluezMake PASS 207.89 seconds MakeCheck PASS 12.85 seconds MakeDistcheck PASS 106.71 seconds CheckValgrind PASS 254.73 seconds CheckSmatch WARNING 183.83 seconds bluezmakeextell PASS 66.09 seconds TestFunctional FAIL 964.96 seconds IncrementalBuild PASS 235.19 seconds ScanBuild PASS 718.77 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
##############################
Test: TestFunctional - FAIL
Desc: Run test-functional
Output:
FAIL functional.test_bap::test_bass_past_earbuds_transport_acquire[hosts11-vm3]: AssertionError: Failed to acquire: org.bluez.Error.Failed
https://github.com/bluez/bluez/pull/2878
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Simon,
Quoted 38 lines · On Sun, Nov 22, 2026 at 6:41 PM <[email protected]> wrote:
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/1218934/---Test result---
Test Summary:
CheckPatch PASS 0.89 seconds GitLint PASS 0.67 seconds BuildEll PASS 13.71 seconds BluezMake PASS 207.89 seconds MakeCheck PASS 12.85 seconds MakeDistcheck PASS 106.71 seconds CheckValgrind PASS 254.73 seconds CheckSmatch WARNING 183.83 seconds bluezmakeextell PASS 66.09 seconds TestFunctional FAIL 964.96 seconds IncrementalBuild PASS 235.19 seconds ScanBuild PASS 718.77 secondsDetails
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/bap.c:317:25: warning: array of flexiblestructuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexiblestructuressrc/shared/bap.c:317:25: warning: array of flexiblestructuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexiblestructuressrc/shared/bap.c:317:25: warning: array of flexiblestructuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
##############################
Test: TestFunctional - FAIL
Desc: Run test-functional
Output:
FAIL functional.test_bap::test_bass_past_earbuds_transport_acquire[hosts11-vm3]: AssertionError: Failed to acquire: org.bluez.Error.Failed
Quoted 1 line
Copilot flagged a problem with these changes:
https://github.com/bluez/bluez/pull/2878#pullrequestreview-6023408098
Signature · 1 line
Luiz Augusto von Dentz