bluez5: require adapter before profile connect & after

All exposed bluez devices should have an adapter specified at all times.
Adapter-less devices appear in some race conditions in BlueZ interface.

Require device has non-null adapter, in all cases before adding any
profiles (which exposes the device), and reject BlueZ profile connection
attempts in that state.

If an adapter gets removed by BlueZ, remove also all its devices, so
that device->adapter pointers stay valid.
This commit is contained in:
Pauli Virtanen 2022-01-19 19:05:37 +02:00 committed by Wim Taymans
parent 870cd0136a
commit f2630ed6fc
4 changed files with 14 additions and 5 deletions

View file

@ -1729,7 +1729,7 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
dbus_message_iter_get_basic(&it[0], &path);
d = spa_bt_device_find(backend->monitor, path);
if (d == NULL) {
if (d == NULL || d->adapter == NULL) {
spa_log_warn(backend->log, "unknown device for path %s", path);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@ -1856,7 +1856,7 @@ static DBusHandlerResult profile_request_disconnection(DBusConnection *conn, DBu
dbus_message_iter_get_basic(&it[0], &path);
d = spa_bt_device_find(backend->monitor, path);
if (d == NULL) {
if (d == NULL || d->adapter == NULL) {
spa_log_warn(backend->log, "unknown device for path %s", path);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}