From: Marcel Holtmann Date: Mon, 30 Jun 2008 06:13:57 +0000 (+0200) Subject: Fix removing elements from list X-Git-Tag: 0.1~312 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=75a6e88c0ba882f357a083b06ac8ba1436a717bb;p=platform%2Fupstream%2Fconnman.git Fix removing elements from list --- diff --git a/plugins/ethernet.c b/plugins/ethernet.c index 03c52d2..8905223 100644 --- a/plugins/ethernet.c +++ b/plugins/ethernet.c @@ -62,23 +62,28 @@ static void create_element(struct connman_element *parent, static void remove_elements(struct connman_element *parent) { - GSList *list; + GSList *list = element_list; DBG("parent %p name %s", parent, parent->name); g_static_mutex_lock(&element_mutex); - for (list = element_list; list; list = list->next) { + while (list) { + GSList *next = list->next; struct connman_element *element = list->data; - if (element->netdev.index != parent->netdev.index) + if (element->netdev.index != parent->netdev.index) { + list = next; continue; + } - element_list = g_slist_remove(element_list, element); + element_list = g_slist_delete_link(element_list, list); connman_element_unregister(element); connman_element_unref(element); + + list = next; } g_static_mutex_unlock(&element_mutex);