From de378e3805f7be9e6185270f932e3e53beaf01c6 Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Wed, 27 Nov 2019 00:52:50 +0100 Subject: [HICN-416] Fix error handling in facemgr netlink interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia04a2f01005ec28a92cc5065ee2f3bddad27f573 Signed-off-by: Jordan Augé --- ctrl/facemgr/src/interfaces/netlink/netlink.c | 49 +++++++++++++++++---------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'ctrl/facemgr') diff --git a/ctrl/facemgr/src/interfaces/netlink/netlink.c b/ctrl/facemgr/src/interfaces/netlink/netlink.c index 653f49d26..62d4fdf90 100644 --- a/ctrl/facemgr/src/interfaces/netlink/netlink.c +++ b/ctrl/facemgr/src/interfaces/netlink/netlink.c @@ -212,13 +212,22 @@ int parse_link(struct nlmsghdr * h, facelet_t ** facelet, *running = ifi->ifi_flags & IFF_RUNNING; - *facelet = facelet_create(); netdevice_t * netdevice = netdevice_create_from_name(interface_name); - if (!netdevice) - goto ERROR_ND; - int rc = facelet_set_netdevice(*facelet, *netdevice); - if (rc < 0) - goto ERROR; + if (!netdevice) { + ERROR("[netlink.parse_link] error creating netdevice '%s'", interface_name); + goto ERR_ND; + } + + *facelet = facelet_create(); + if (!*facelet) { + ERROR("[netlink.parse_link] error creating facelet"); + goto ERR_FACELET; + } + + if (facelet_set_netdevice(*facelet, *netdevice) < 0) { + ERROR("[netlink.parse_link] error setting netdevice"); + goto ERR; + } // FIXME Tags #if 0 @@ -250,12 +259,12 @@ int parse_link(struct nlmsghdr * h, facelet_t ** facelet, netdevice_free(netdevice); return 0; -ERROR: - netdevice_free(netdevice); -ERROR_ND: +ERR: facelet_free(*facelet); *facelet = NULL; - +ERR_FACELET: + netdevice_free(netdevice); +ERR_ND: return -1; } @@ -316,7 +325,7 @@ int parse_addr(struct nlmsghdr * h, facelet_t ** facelet, netdevice_t * netdevice = netdevice_create_from_index(ifa->ifa_index); if (!netdevice) { ERROR("[netlink.parse_addr] error creating netdevice '%s'", interface_name); - goto ERROR_ND; + goto ERR_ND; } if (interface_name) { @@ -324,28 +333,32 @@ int parse_addr(struct nlmsghdr * h, facelet_t ** facelet, } *facelet = facelet_create(); + if (!*facelet) { + ERROR("[netlink.parse_addr] error creating facelet"); + goto ERR_FACELET; + } if (facelet_set_netdevice(*facelet, *netdevice) < 0) { ERROR("[netlink.parse_addr] error setting netdevice"); - goto ERROR; + goto ERR; } if (facelet_set_family(*facelet, ifa->ifa_family) < 0) { ERROR("[netlink.parse_addr] error setting family"); - goto ERROR; + goto ERR; } if (facelet_set_local_addr(*facelet, local_addr) < 0) { ERROR("[netlink.parse_addr] error setting local address"); - goto ERROR; + goto ERR; } netdevice_free(netdevice); return 0; -ERROR: - netdevice_free(netdevice); -ERROR_ND: +ERR: facelet_free(*facelet); *facelet = NULL; - +ERR_FACELET: + netdevice_free(netdevice); +ERR_ND: return -1; } -- cgit 1.2.3-korg