diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-12-18 00:11:05 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-12-18 00:11:05 +0100 |
commit | 0f461fae5f251b9598b4b470f52ca9af575c0cc2 (patch) | |
tree | c16902967b077aec65cff9825702c6b909fb83a9 /plugins | |
parent | 6e8f721b4b86da751efcdbfdec4ccf526f1cba34 (diff) | |
download | connman-0f461fae5f251b9598b4b470f52ca9af575c0cc2.tar.gz connman-0f461fae5f251b9598b4b470f52ca9af575c0cc2.tar.bz2 connman-0f461fae5f251b9598b4b470f52ca9af575c0cc2.zip |
Handle element registration failures
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/dhclient.c | 3 | ||||
-rw-r--r-- | plugins/ethernet.c | 3 | ||||
-rw-r--r-- | plugins/ipv4.c | 3 | ||||
-rw-r--r-- | plugins/netdev.c | 3 | ||||
-rw-r--r-- | plugins/rtnllink.c | 6 | ||||
-rw-r--r-- | plugins/wifi.c | 15 |
6 files changed, 25 insertions, 8 deletions
diff --git a/plugins/dhclient.c b/plugins/dhclient.c index 3d6f189b..06083b65 100644 --- a/plugins/dhclient.c +++ b/plugins/dhclient.c @@ -296,7 +296,8 @@ static DBusHandlerResult dhclient_filter(DBusConnection *conn, element->type = CONNMAN_ELEMENT_TYPE_IPV4; element->index = task->ifindex; connman_element_update(task->element); - connman_element_register(element, task->element); + if (connman_element_register(element, task->element) < 0) + connman_element_unref(element); } else if (g_ascii_strcasecmp(text, "RENEW") == 0 || g_ascii_strcasecmp(text, "REBIND") == 0) { connman_element_update(task->element); diff --git a/plugins/ethernet.c b/plugins/ethernet.c index 832d636f..9cfa76bd 100644 --- a/plugins/ethernet.c +++ b/plugins/ethernet.c @@ -76,7 +76,8 @@ static void ethernet_newlink(unsigned short type, int index, netdev->subtype = CONNMAN_ELEMENT_SUBTYPE_NETWORK; netdev->index = element->index; - connman_element_register(netdev, element); + if (connman_element_register(netdev, element) < 0) + connman_element_unref(netdev); } } else { DBG("carrier off"); diff --git a/plugins/ipv4.c b/plugins/ipv4.c index b1c26d4b..b7d79be8 100644 --- a/plugins/ipv4.c +++ b/plugins/ipv4.c @@ -399,7 +399,8 @@ static int ipv4_probe(struct connman_element *element) connection->type = CONNMAN_ELEMENT_TYPE_CONNECTION; connection->index = element->index; - connman_element_register(connection, element); + if (connman_element_register(connection, element) < 0) + connman_element_unref(connection); return 0; } diff --git a/plugins/netdev.c b/plugins/netdev.c index 3e085346..b32c12f0 100644 --- a/plugins/netdev.c +++ b/plugins/netdev.c @@ -46,7 +46,8 @@ static void create_element(struct connman_element *parent, else element->subtype = CONNMAN_ELEMENT_SUBTYPE_UNKNOWN; - connman_element_register(element, parent); + if (connman_element_register(element, parent) < 0) + connman_element_unref(element); } static int netdev_probe(struct connman_element *element) diff --git a/plugins/rtnllink.c b/plugins/rtnllink.c index b0ed247f..e7acc5ff 100644 --- a/plugins/rtnllink.c +++ b/plugins/rtnllink.c @@ -110,7 +110,11 @@ static void rtnllink_newlink(unsigned short type, int index, device->name = name; device->devname = devname; - connman_element_register(device, NULL); + if (connman_element_register(device, NULL) < 0) { + connman_element_unref(device); + return; + } + device_list = g_slist_append(device_list, device); } diff --git a/plugins/wifi.c b/plugins/wifi.c index aa6021da..23fbb892 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -243,7 +243,8 @@ static void state_change(struct connman_element *device, dhcp->type = CONNMAN_ELEMENT_TYPE_DHCP; dhcp->index = element->index; - connman_element_register(dhcp, element); + if (connman_element_register(dhcp, element) < 0) + connman_element_unref(dhcp); } else if (state == STATE_INACTIVE || state == STATE_DISCONNECTED) { data->connected = FALSE; connman_element_set_enabled(element, FALSE); @@ -363,7 +364,10 @@ static void scan_result(struct connman_element *device, DBG("%s (%s) strength %d", network->identifier, element->wifi.security, element->strength); - connman_element_register(element, device); + if (connman_element_register(element, device) < 0) { + connman_element_unref(element); + goto done; + } } else { data->pending = g_slist_remove(data->pending, element); @@ -381,6 +385,7 @@ static void scan_result(struct connman_element *device, element->available = TRUE; +done: g_free(temp); } @@ -553,7 +558,11 @@ static void wifi_newlink(unsigned short type, int index, device->name = name; device->devname = devname; - connman_element_register(device, NULL); + if (connman_element_register(device, NULL) < 0) { + connman_element_unregister(device); + return; + } + device_list = g_slist_append(device_list, device); } |