From 56670755c16d21c6930dc429b602fd8818311575 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Tue, 16 Jul 2019 17:49:43 -0700 Subject: [PATCH] netconfig: Refactor rtnl error handling Keep the rtnl destruction code in one place as it will have a few more usages in the future. --- src/netconfig.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/netconfig.c b/src/netconfig.c index 25fc2c63..35904132 100644 --- a/src/netconfig.c +++ b/src/netconfig.c @@ -604,24 +604,24 @@ static int netconfig_init(void) if (!r) { l_error("netconfig: Failed to register for RTNL link address" " notifications."); - l_netlink_destroy(rtnl); - rtnl = NULL; - - return r; + goto error; } r = rtnl_ifaddr_get(rtnl, netconfig_ifaddr_cmd_cb, NULL, NULL); if (!r) { l_error("netconfig: Failed to get addresses from RTNL link."); - l_netlink_destroy(rtnl); - rtnl = NULL; - - return r; + goto error; } netconfig_list = l_queue_new(); return 0; + +error: + l_netlink_destroy(rtnl); + rtnl = NULL; + + return r; } static void netconfig_exit(void)