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 2a8e7da..75561c9 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 b99a867..fc4cd01 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;
 }
 
 /**