Reset connman_network device pointer when it is no longer referenced
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 8 Apr 2010 22:19:07 +0000 (00:19 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 8 Apr 2010 22:24:07 +0000 (00:24 +0200)
When removing all networks from a device, network->device pointers are
set to NULL even though the network is still referenced. This can lead
to segmentation faults when for example a service has several networks
and is being disconnected.

src/device.c
src/network.c

index 2a8e7dab72feea68b180ce739cdb6b4f7d80dc32..75561c9f8046d92240d80429d9b5592413c7ce6f 100644 (file)
@@ -656,8 +656,6 @@ static void unregister_network(gpointer data)
        connman_element_unregister((struct connman_element *) network);
 
        connman_network_unref(network);
-
-       __connman_network_set_device(network, NULL);
 }
 
 static void device_destruct(struct connman_element *element)
@@ -1468,6 +1466,9 @@ void __connman_device_set_network(struct connman_device *device,
 {
        const char *name;
 
+       if (device == NULL)
+               return;
+
        if (device->network == network)
                return;
 
index b99a86755062f7ed3a813ebe9e7313a60323ec66..fc4cd01024f214f9ba4025abe1def33b45799692 100644 (file)
@@ -314,6 +314,8 @@ static void network_destruct(struct connman_element *element)
                connman_ipconfig_unref(network->ipconfig);
                network->ipconfig = NULL;
        }
+
+       network->device = NULL;
 }
 
 /**