summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
index 52fae4ed..5c8208de 100644
--- a/src/device.c
+++ b/src/device.c
@@ -111,10 +111,15 @@ static GSList *device_drivers = NULL;
static void device_free(gpointer user_data)
{
struct btd_device *device = user_data;
+ struct btd_adapter *adapter = device->adapter;
+ struct agent *agent = adapter_get_agent(adapter);
if (device->agent)
agent_destroy(device->agent, FALSE);
+ if (agent && agent_is_busy(agent, device))
+ agent_cancel(agent);
+
g_slist_foreach(device->uuids, (GFunc) g_free, NULL);
g_slist_free(device->uuids);