diff options
-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; } |