diff options
author | Tom Gundersen <teg@jklm.no> | 2014-07-03 09:55:59 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-07-03 11:00:01 +0200 |
commit | ad0774e61e436d052f93549fc7fd367ade069286 (patch) | |
tree | c65ca8350bd7330fd5e5c6bab3900bdc97045537 | |
parent | 563c69c6b2c2bd691352ef522cb9ec95c08a0c63 (diff) |
networkd: netdev - drop the link callbacks after calling them once
We should never call them again, so make sure they are cleaned up correctly.
-rw-r--r-- | src/network/networkd-netdev.c | 13 |
1 files changed, 10 insertions, 3 deletions
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; |