From ad0774e61e436d052f93549fc7fd367ade069286 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Thu, 3 Jul 2014 09:55:59 +0200 Subject: networkd: netdev - drop the link callbacks after calling them once We should never call them again, so make sure they are cleaned up correctly. --- src/network/networkd-netdev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/network') diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 0861ff3cc1..eaa8bede7a 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -192,7 +192,8 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand } static int netdev_enter_ready(NetDev *netdev) { - netdev_enslave_callback *callback; + netdev_enslave_callback *callback, *callback_next; + int r; assert(netdev); assert(netdev->ifname); @@ -204,10 +205,16 @@ static int netdev_enter_ready(NetDev *netdev) { log_info_netdev(netdev, "netdev ready"); - LIST_FOREACH(callbacks, callback, netdev->callbacks) { + LIST_FOREACH_SAFE(callbacks, callback, callback_next, netdev->callbacks) { /* enslave the links that were attempted to be enslaved before the * link was ready */ - netdev_enslave_ready(netdev, callback->link, callback->callback); + r = netdev_enslave_ready(netdev, callback->link, callback->callback); + if (r < 0) + return r; + + LIST_REMOVE(callbacks, netdev->callbacks, callback); + link_unref(callback->link); + free(callback); } return 0; -- cgit v1.2.3-54-g00ecf