summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2018-12-21 12:42:34 -0800
committerDamjan Marion <dmarion@me.com>2018-12-22 11:50:40 +0000
commit27ca2982e1ac5c6f6a980f40c0906f8d8fb857ef (patch)
tree9f06912ceca9a5911f2bb8196988f20c963aede4 /src/vnet/devices
parentb9894ee69f6ba9c6a8eeb531d528e656b2a07812 (diff)
tapv2: coverity woe
coverity complains about fd leaking inside the if statement because there is a goto which bypasses the statement close (fd). The fix is to close (fd) immediately after it is no longer used. Change-Id: Ic5035b07ec1f179ff3db77744843e47aa8067a3c Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/tap/tap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index 3bbdd05cd4d..d0ed58c1f06 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -182,6 +182,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
if (args->host_namespace)
{
int fd;
+ int rc;
old_netns_fd = open ("/proc/self/ns/net", O_RDONLY);
if ((fd = open_netns_fd ((char *) args->host_namespace)) == -1)
{
@@ -197,14 +198,15 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
args->rv = VNET_API_ERROR_NETLINK_ERROR;
goto error;
}
- if (setns (fd, CLONE_NEWNET) == -1)
+ rc = setns (fd, CLONE_NEWNET);
+ close (fd);
+ if (rc == -1)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;
args->error = clib_error_return_unix (0, "setns '%s'",
args->host_namespace);
goto error;
}
- close (fd);
if ((vif->ifindex = if_nametoindex ((char *) args->host_if_name)) == 0)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;