diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-04-05 07:14:51 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-04-07 11:44:35 +0200 |
commit | 48bc843d6e406a142b5b07e57a3d7d242c2bed03 (patch) | |
tree | 532e34f3e271837c4a4d326fe8187db727467356 | |
parent | 22ed4467a413961816f317c641e436ca627d06d2 (diff) | |
download | passt-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; } |