summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/plugin.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/hcid/plugin.c b/hcid/plugin.c
index 29f11714..ca43ae72 100644
--- a/hcid/plugin.c
+++ b/hcid/plugin.c
@@ -240,9 +240,26 @@ int plugin_req_auth(bdaddr_t *src, bdaddr_t *dst,
int plugin_cancel_auth(bdaddr_t *src)
{
struct adapter *adapter = ba2adapter(src);
+ struct device *device;
+ struct agent *agent;
+ char address[18];
+
+ if (!adapter)
+ return -EPERM;
- if (!adapter || !adapter->agent)
+ ba2str(src, address);
+ device = adapter_find_device(adapter, address);
+ if (!device)
+ return -EPERM;
+
+ /*
+ * FIXME: Cancel fails if authorization is requested to adapter's
+ * agent and in the meanwhile CreatePairedDevice is called.
+ */
+
+ agent = (device->agent ? : adapter->agent);
+ if (!agent)
return -EPERM;
- return agent_cancel(adapter->agent);
+ return agent_cancel(agent);
}