while https://gerrit.fd.io/r/#/c/16590/ fixed the leaked fd which coverity
reported at that time, new coverity run reports simailar leaked fd in a
different goto punt path. It would be nice if coverity reported both of them
at the same time. Or perhaps it did and I just missed it. Anyway, the new fix
is to put the close (fd) statement prior to the return of tap_create_if routine
which should catch all goto's.
Change-Id: I0a51ed3710e32d5d74c9cd9b5066a667153e2f9d
Signed-off-by: Steven Luong <sluong@cisco.com>
struct vhost_memory *vhost_mem = 0;
virtio_if_t *vif = 0;
clib_error_t *err = 0;
struct vhost_memory *vhost_mem = 0;
virtio_if_t *vif = 0;
clib_error_t *err = 0;
after we change our net namespace */
if (args->host_namespace)
{
after we change our net namespace */
if (args->host_namespace)
{
old_netns_fd = open ("/proc/self/ns/net", O_RDONLY);
if ((fd = open_netns_fd ((char *) args->host_namespace)) == -1)
{
old_netns_fd = open ("/proc/self/ns/net", O_RDONLY);
if ((fd = open_netns_fd ((char *) args->host_namespace)) == -1)
{
args->rv = VNET_API_ERROR_NETLINK_ERROR;
goto error;
}
args->rv = VNET_API_ERROR_NETLINK_ERROR;
goto error;
}
- rc = setns (fd, CLONE_NEWNET);
- close (fd);
- if (rc == -1)
+ if (setns (fd, CLONE_NEWNET) == -1)
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;
args->error = clib_error_return_unix (0, "setns '%s'",
{
args->rv = VNET_API_ERROR_SYSCALL_ERROR_3;
args->error = clib_error_return_unix (0, "setns '%s'",
clib_mem_free (vhost_mem);
if (old_netns_fd != -1)
close (old_netns_fd);
clib_mem_free (vhost_mem);
if (old_netns_fd != -1)
close (old_netns_fd);
+ if (fd != -1)
+ close (fd);