When bluetooth daemon disappears gracefully transports are freed before
the daemon disappears from DBus bus. However if bluetooth daemon
segfaults or is killed abruptly the daemon disappears from the bus
before PulseAudio is able to clean the transports. As the devices
and adapters are freed before ofono or native backends, PulseAudio
segfaults when dangling pointers are used when freeing the backends.
Fix by freeing the backends before devices and adapters when bluetooth
daemon disappears from DBus bus.

Signed-off-by: Juho Hämäläinen <[email protected]>
---
 src/modules/bluetooth/bluez5-util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/bluez5-util.c 
b/src/modules/bluetooth/bluez5-util.c
index 2d83373..f71e458 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -1125,9 +1125,6 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, 
DBusMessage *m, void *us
         if (pa_streq(name, BLUEZ_SERVICE)) {
             if (old_owner && *old_owner) {
                 pa_log_debug("Bluetooth daemon disappeared");
-                pa_hashmap_remove_all(y->devices);
-                pa_hashmap_remove_all(y->adapters);
-                y->objects_listed = false;
                 if (y->ofono_backend) {
                     pa_bluetooth_ofono_backend_free(y->ofono_backend);
                     y->ofono_backend = NULL;
@@ -1136,6 +1133,9 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, 
DBusMessage *m, void *us
                     pa_bluetooth_native_backend_free(y->native_backend);
                     y->native_backend = NULL;
                 }
+                pa_hashmap_remove_all(y->devices);
+                pa_hashmap_remove_all(y->adapters);
+                y->objects_listed = false;
             }
 
             if (new_owner && *new_owner) {
-- 
2.7.4

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to