From a1d4769eca276ef23a55cb486b11aeb6e9790ad1 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Tue, 23 Jan 2024 11:52:04 +0100 Subject: [PATCH] bgpd: fix memory leak in rpki_create_socket Fix memory leak in rpki_create_socket. Coverity scanner issue 1575914. Fixes: a951752 ("bgpd: create cache server socket in vrf") Signed-off-by: Louis Scalbert --- bgpd/bgp_rpki.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 2c716a0e28ba..65f4f1e08975 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -1343,8 +1343,10 @@ static int rpki_create_socket(void *_cache) socket = vrf_socket(res->ai_family, res->ai_socktype, res->ai_protocol, vrf->vrf_id, NULL); } - if (socket < 0) + if (socket < 0) { + freeaddrinfo(res); return -1; + } pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &cancel_state); timeout.tv_sec = 30;