PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
1a3ffd4c by Igor V. Kovalenko at 2021-11-17T15:30:03+00:00
bluetooth: Fix device->adapter dependency while releasing discovery

Change d7f95170a1ee3589158ce8f5baa6fabcb802bbf5 added a dependency on device
adapter pointer being valid while checking if bluetooth profile is supported by
device.

When adapter object is released, each device holding pointer to adapter being
released is notified to reset that to NULL. Since adapter objects are released
first when discovery object is unreferenced, each device will have adapter
pointer reset before the time device objects are released.

Fix observed crash by examining device adapter pointer. If it is NULL report
that device does not support any bluetooth profile instead of looking at UUIDs
supported by adapter.

Part-of: 
<https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/646>

- - - - -


1 changed file:

- src/modules/bluetooth/bluez5-util.c


Changes:

=====================================
src/modules/bluetooth/bluez5-util.c
=====================================
@@ -257,6 +257,17 @@ static const char 
*transport_state_to_string(pa_bluetooth_transport_state_t stat
 bool pa_bluetooth_device_supports_profile(const pa_bluetooth_device *device, 
pa_bluetooth_profile_t profile) {
     bool show_hfp, show_hsp, r;
 
+    pa_assert(device);
+
+    /* While discovery is being released adapters will be removed from devices,
+     * and there are no profiles to support without adapter.
+     */
+    if (!device->adapter) {
+        pa_log_debug("Device %s (%s) has no adapter to support profile %s",
+                device->alias, device->address, 
pa_bluetooth_profile_to_string(profile));
+        return false;
+    }
+
     if (device->enable_hfp_hf) {
         show_hfp = pa_hashmap_get(device->uuids, PA_BLUETOOTH_UUID_HFP_HF);
         show_hsp = !show_hfp;



View it on GitLab: 
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/1a3ffd4cee4b350c5222c2790fa635da46aa5ff7

-- 
View it on GitLab: 
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/1a3ffd4cee4b350c5222c2790fa635da46aa5ff7
You're receiving this email because of your account on gitlab.freedesktop.org.


Reply via email to