In case hci_get_route() failed mark first adapter on list as default. This make sure default adapter is always set and that btd_adapter_get_default will not return NULL if at least one adapter is registered. --- src/adapter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 3f51fd4..7b08425 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5523,8 +5523,10 @@ static int adapter_unregister(struct btd_adapter *adapter) struct btd_adapter *new_default; new_default = adapter_find_by_id(hci_get_route(NULL)); - if (new_default) - new_default->is_default = true; + if (new_default == NULL) + new_default = adapters->data; + + new_default->is_default = true; } adapter_list = g_list_remove(adapter_list, adapter); -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html