diff --git a/src/adapter.c b/src/adapter.c
index df06d1d..e1b8d5d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
/* Return adapter to down state if it was not up on init */
adapter_ops->restore_powered(adapter->dev_id);
-
- btd_adapter_unref(adapter);
}
uint16_t adapter_get_dev_id(struct btd_adapter *adapter)
diff --git a/src/manager.c b/src/manager.c
index a725588..464b0ca 100644
--- a/src/manager.c
+++ b/src/manager.c
DBUS_TYPE_INVALID);
adapter_remove(adapter);
+ btd_adapter_unref(adapter);
if (adapters == NULL)
btd_start_exit_timer();
void manager_cleanup(DBusConnection *conn, const char *path)
{
- g_slist_free_full(adapters, (GDestroyNotify) adapter_remove);
+ while (adapters) {
+ struct btd_adapter *adapter = adapters->data;
+
+ adapters = g_slist_remove(adapters, adapter);
+ adapter_remove(adapter);
+ btd_adapter_unref(adapter);
+ }
- adapters = NULL;
btd_start_exit_timer();
g_dbus_unregister_interface(conn, "/", MANAGER_INTERFACE);