aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/socket.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c
index 26427d98fa1..2921e008018 100644
--- a/src/vppinfra/socket.c
+++ b/src/vppinfra/socket.c
@@ -560,7 +560,7 @@ clib_socket_init_netns (clib_socket_t *s, u8 *namespace)
return clib_socket_init (s);
clib_error_t *error;
- int old_netns_fd, nfd;
+ int old_netns_fd, nfd = -1;
old_netns_fd = clib_netns_open (NULL /* self */);
if ((nfd = clib_netns_open (namespace)) == -1)
@@ -580,8 +580,12 @@ clib_socket_init_netns (clib_socket_t *s, u8 *namespace)
done:
if (clib_setns (old_netns_fd) == -1)
clib_warning ("Cannot set old ns");
+
close (old_netns_fd);
+ if (-1 != nfd)
+ close (nfd);
+
return error;
}