1
0
mirror of https://passt.top/passt synced 2024-07-01 23:42:41 +00:00

tap: Resource leak, CWE-404

Reported by Coverity.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-04-05 07:14:51 +02:00
parent 22ed4467a4
commit 48bc843d6e

5
tap.c
View File

@ -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;
}