From: Marcel Röthke Date: Thu, 22 Aug 2019 13:49:58 +0000 (+0200) Subject: bgpd: cleanup properly if rtr mgr cannot add a cache X-Git-Tag: base_7.2~6^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=6893064b4287c861a6062b7c647cd77f7e0a09f0;p=matthieu%2Ffrr.git bgpd: cleanup properly if rtr mgr cannot add a cache Signed-off-by: Marcel Röthke --- diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 32f599745f..28d14ccb8c 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -756,8 +756,6 @@ static int add_cache(struct cache *cache) group.sockets_len = 1; group.sockets = &cache->rtr_socket; - listnode_add(cache_list, cache); - if (rtr_is_running) { init_tr_socket(cache); @@ -767,6 +765,8 @@ static int add_cache(struct cache *cache) } } + listnode_add(cache_list, cache); + return SUCCESS; } @@ -793,7 +793,12 @@ static int add_tcp_cache(const char *host, const char *port, cache->rtr_socket = rtr_socket; cache->preference = preference; - return add_cache(cache); + int ret = add_cache(cache); + if (ret != SUCCESS) { + free_cache(cache); + } + + return ret; } #if defined(FOUND_SSH) @@ -829,7 +834,12 @@ static int add_ssh_cache(const char *host, const unsigned int port, cache->rtr_socket = rtr_socket; cache->preference = preference; - return add_cache(cache); + int ret = add_cache(cache); + if (ret != SUCCESS) { + free_cache(cache); + } + + return ret; } #endif