diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index afb2215..8cf7189 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
static void bluetooth_exit(void)
{
+ GSList *l;
+
g_dbus_remove_watch(connection, listener_id);
- g_slist_free_full(profiles, profile_free);
+ for (l = profiles; l; l = l->next) {
+ struct bluetooth_profile *profile = l->data;
+
+ if (profile->path == NULL)
+ continue;
+
+ unregister_profile(profile);
+ }
- if (connection)
+ if (connection) {
+ dbus_connection_close(connection);
dbus_connection_unref(connection);
+ connection = NULL;
+ }
obex_transport_driver_unregister(&driver);
}