Skip to content

Commit

Permalink
main: do not leak tapfd
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Feb 6, 2024
1 parent fa1f950 commit afc3126
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ static int child(int sock, pid_t target_pid, bool do_config_network,
return tapfd;
}
if (do_config_network && configure_network(tapname, cfg) < 0) {
close(tapfd);
return -1;
}
if (sendfd(sock, tapfd) < 0) {
Expand All @@ -252,6 +253,7 @@ static int child(int sock, pid_t target_pid, bool do_config_network,
return -1;
}
fprintf(stderr, "sent tapfd=%d for %s\n", tapfd, tapname);
close(tapfd);
close(sock);
return 0;
}
Expand Down

0 comments on commit afc3126

Please sign in to comment.