aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 07:14:51 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commit48bc843d6e406a142b5b07e57a3d7d242c2bed03 (patch)
tree532e34f3e271837c4a4d326fe8187db727467356
parent22ed4467a413961816f317c641e436ca627d06d2 (diff)
downloadpasst-48bc843d6e406a142b5b07e57a3d7d242c2bed03.tar
passt-48bc843d6e406a142b5b07e57a3d7d242c2bed03.tar.gz
passt-48bc843d6e406a142b5b07e57a3d7d242c2bed03.tar.bz2
passt-48bc843d6e406a142b5b07e57a3d7d242c2bed03.tar.lz
passt-48bc843d6e406a142b5b07e57a3d7d242c2bed03.tar.xz
passt-48bc843d6e406a142b5b07e57a3d7d242c2bed03.tar.zst
passt-48bc843d6e406a142b5b07e57a3d7d242c2bed03.zip
tap: Resource leak, CWE-404
Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tap.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tap.c b/tap.c
index e4dd804..8310891 100644
--- a/tap.c
+++ b/tap.c
@@ -899,8 +899,11 @@ static int tap_ns_tun(void *arg)
if (ns_enter(c) ||
(tun_ns_fd = open("/dev/net/tun", flags)) < 0 ||
ioctl(tun_ns_fd, TUNSETIFF, &ifr) ||
- !(c->pasta_ifi = if_nametoindex(c->pasta_ifn)))
+ !(c->pasta_ifi = if_nametoindex(c->pasta_ifn))) {
+ if (tun_ns_fd != -1)
+ close(tun_ns_fd);
tun_ns_fd = -1;
+ }
return 0;
}