Set device before registering network
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 30 Dec 2008 21:58:41 +0000 (22:58 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 30 Dec 2008 21:58:41 +0000 (22:58 +0100)
src/device.c

index 5b7ac4f..84be26e 100644 (file)
@@ -836,12 +836,14 @@ int connman_device_add_network(struct connman_device *device,
        if (device->mode == CONNMAN_DEVICE_MODE_NO_NETWORK)
                return -EINVAL;
 
+       __connman_network_set_device(network, device);
+
        err = connman_element_register((struct connman_element *) network,
                                                        &device->element);
-       if (err < 0)
+       if (err < 0) {
+               __connman_network_set_device(network, NULL);
                return err;
-
-       __connman_network_set_device(network, device);
+       }
 
        g_hash_table_insert(device->networks, g_strdup(identifier),
                                                                network);