Add patch to avoid segfault in bluez5 (rhbz#2041481)

This commit is contained in:
Wim Taymans 2022-01-18 16:15:45 +01:00
parent e7f81f45c8
commit f62fda330b
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 070ec05984e23bc68e737683e6e707b537606683 Mon Sep 17 00:00:00 2001
From: Pauli Virtanen <pav@iki.fi>
Date: Mon, 17 Jan 2022 19:10:14 +0200
Subject: [PATCH] bluez5: don't create device if adapter is missing
BlueZ may be missing adapter information for devices in some cases.
Ignore devices without specified adapter.
---
spa/plugins/bluez5/bluez5-dbus.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c
index 32d540bf1..85ababc0d 100644
--- a/spa/plugins/bluez5/bluez5-dbus.c
+++ b/spa/plugins/bluez5/bluez5-dbus.c
@@ -1455,6 +1455,15 @@ static int device_update_props(struct spa_bt_device *device,
return 0;
}
+static bool device_props_ready(struct spa_bt_device *device)
+{
+ /*
+ * In some cases, BlueZ device props may be missing part of
+ * the information required when the interface first appears.
+ */
+ return device->adapter && device->address;
+}
+
bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec *codec)
{
struct spa_bt_monitor *monitor = device->monitor;
@@ -3607,6 +3616,9 @@ static void interface_added(struct spa_bt_monitor *monitor,
device_update_props(d, props_iter, NULL);
d->reconnect_state = BT_DEVICE_RECONNECT_INIT;
+ if (!device_props_ready(d))
+ return;
+
device_update_hw_volume_profiles(d);
/* Trigger bluez device creation before bluez profile negotiation started so that
@@ -3963,6 +3975,12 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
spa_log_debug(monitor->log, "Properties changed in device %s", path);
device_update_props(d, &it[1], NULL);
+
+ if (!device_props_ready(d))
+ goto finish;
+
+ device_update_hw_volume_profiles(d);
+
spa_bt_device_add_profile(d, SPA_BT_PROFILE_NULL);
}
else if (spa_streq(iface, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) {
--
2.31.1

View File

@ -9,7 +9,7 @@
%global ms_version 0.4.1
# For rpmdev-bumpspec and releng automation
%global baserelease 2
%global baserelease 3
#global snapdate 20210107
#global gitcommit b17db2cebc1a5ab2c01851d29c05f79cd2f262bb
@ -75,6 +75,7 @@ Source1: https://gitlab.freedesktop.org/pipewire/media-session/-/archive/
## upstream patches
Patch0001: 0003-audioconvert-avoid-infinite-loop.patch
Patch0002: 0004-bluez5-handle-missing-device-and-adapter-in-quirks.patch
Patch0003: 0001-bluez5-don-t-create-device-if-adapter-is-missing.patch
## upstreamable patches
@ -604,6 +605,9 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || :
%endif
%changelog
* Tue Jan 18 2022 Wim Taymans <wtaymans@redhat.com> - 0.3.43-3
- Add patch to avoid segfault in bluez5 (rhbz#2041481)
* Mon Jan 17 2022 Wim Taymans <wtaymans@redhat.com> - 0.3.43-2
- Add patch to avoid segfault in bluez5 (rhbz#2041481)