summaryrefslogtreecommitdiffstats
path: root/hcid/main.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-08-18 22:32:10 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-08-18 22:32:10 +0000
commit49852c0b4fe1ef1dae5d11e7ff01b70c12464e40 (patch)
tree629e3bb0864ad6362eea38a594729fb7a8946be2 /hcid/main.c
parent14c1a4ad4c1fd5b86d3664707d76801013caa741 (diff)
Fix accessing free'd memory
Diffstat (limited to 'hcid/main.c')
-rw-r--r--hcid/main.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/hcid/main.c b/hcid/main.c
index d69326dc..3aea1a89 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -478,7 +478,19 @@ static void init_all_devices(int ctl)
for (i = 0; i < dl->dev_num; i++, dr++) {
if (hcid.auto_init)
init_device(dr->dev_id);
+
+ add_device(dr->dev_id);
+
+ if (hcid.auto_init && hci_test_bit(HCI_UP, &dr->dev_opt))
+ configure_device(dr->dev_id);
+
+ if (hcid.security && hci_test_bit(HCI_UP, &dr->dev_opt))
+ start_security_manager(dr->dev_id);
+
+ start_device(dr->dev_id);
+
hcid_dbus_register_device(dr->dev_id);
+ hcid_dbus_start_device(dr->dev_id);
}
free(dl);
@@ -520,6 +532,7 @@ static inline void device_event(GIOChannel *chan, evt_stack_internal *si)
info("HCI dev %d registered", sd->dev_id);
if (hcid.auto_init)
init_device(sd->dev_id);
+ add_device(sd->dev_id);
hcid_dbus_register_device(sd->dev_id);
break;
@@ -531,7 +544,6 @@ static inline void device_event(GIOChannel *chan, evt_stack_internal *si)
case HCI_DEV_UP:
info("HCI dev %d up", sd->dev_id);
- add_device(sd->dev_id);
if (hcid.auto_init)
configure_device(sd->dev_id);
if (hcid.security)
@@ -705,13 +717,13 @@ int main(int argc, char *argv[])
/* Create event loop */
event_loop = g_main_new(FALSE);
+ /* Initialize already connected devices */
+ init_all_devices(hcid.sock);
+
ctl_io = g_io_channel_unix_new(hcid.sock);
g_io_add_watch(ctl_io, G_IO_IN, io_stack_event, NULL);
- /* Initialize already connected devices */
- init_all_devices(hcid.sock);
-
if (sdp)
start_sdp_server();