summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/dbus.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c
index daeb93bd..e8c5ec41 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -460,12 +460,17 @@ static gboolean unregister_dbus_path(const char *path)
void hcid_dbus_request_pin(int dev, struct hci_conn_info *ci)
{
- DBusMessage *message;
+ DBusMessage *message = NULL;
DBusPendingCall *pending = NULL;
struct pin_request *req;
uint8_t *addr = (uint8_t *) &ci->bdaddr;
dbus_bool_t out = ci->out;
+ if (!connection) {
+ if (!hcid_dbus_init())
+ goto failed;
+ }
+
message = dbus_message_new_method_call(PINAGENT_SERVICE_NAME, PINAGENT_PATH,
PINAGENT_INTERFACE, PIN_REQUEST);
if (message == NULL) {
@@ -497,7 +502,9 @@ void hcid_dbus_request_pin(int dev, struct hci_conn_info *ci)
return;
failed:
- dbus_message_unref(message);
+ if (message)
+ dbus_message_unref(message);
+
hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, &ci->bdaddr);
}