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

@ -364,7 +364,7 @@ static DBusHandlerResult ofono_audio_card_found(struct impl *backend, char *path
}
d = spa_bt_device_find_by_address(backend->monitor, remote_address, local_address);
if (!d) {
if (!d || !d->adapter) {
spa_log_error(backend->log, "Device doesnt exist for %s", path);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}