From e6bc224ee0031b7f3aad6e696fb3d5bc41496dc7 Mon Sep 17 00:00:00 2001 From: Zach Dworkin Date: Fri, 19 Jan 2024 09:27:06 -0800 Subject: [PATCH] prov/shm: Fix coverity issue about resource leak Sock variable handle goes out of scope and leaks the handle. This cleans it up properly. Signed-off-by: Zach Dworkin --- prov/shm/src/smr_ep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prov/shm/src/smr_ep.c b/prov/shm/src/smr_ep.c index 07b5fa4443d..e6f57629099 100644 --- a/prov/shm/src/smr_ep.c +++ b/prov/shm/src/smr_ep.c @@ -1037,8 +1037,10 @@ static void *smr_start_listener(void *args) ep->sock_info->peers[id].device_fds = calloc(ep->sock_info->nfds, sizeof(*ep->sock_info->peers[id].device_fds)); - if (!ep->sock_info->peers[id].device_fds) + if (!ep->sock_info->peers[id].device_fds) { + close(sock); goto out; + } } memcpy(ep->sock_info->peers[id].device_fds, peer_fds, sizeof(*peer_fds) *