From 14db5768a4ae913bf970ac4577c82da0b33a5ddc Mon Sep 17 00:00:00 2001 From: Zach Dworkin Date: Fri, 19 Jan 2024 09:27:06 -0800 Subject: [PATCH] [v1.19.x] 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 (cherry picked from commit e6bc224ee0031b7f3aad6e696fb3d5bc41496dc7) --- 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 f7fb0bb2b17..e91b4b5dc15 100644 --- a/prov/shm/src/smr_ep.c +++ b/prov/shm/src/smr_ep.c @@ -1018,8 +1018,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) *