Skip to content

Commit

Permalink
qemu-bridge-helper: Fix fd leak in main()
Browse files Browse the repository at this point in the history
initialize fd and ctlfd, and close them at the end

Signed-off-by: Gonglei <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
  • Loading branch information
gongleiarei authored and stefanhaRH committed Jun 27, 2014
1 parent ff4873c commit eb3f45c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions qemu-bridge-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int main(int argc, char **argv)
unsigned long ifargs[4];
#endif
int ifindex;
int fd, ctlfd, unixfd = -1;
int fd = -1, ctlfd = -1, unixfd = -1;
int use_vnet = 0;
int mtu;
const char *bridge = NULL;
Expand Down Expand Up @@ -436,7 +436,12 @@ int main(int argc, char **argv)
/* profit! */

cleanup:

if (fd >= 0) {
close(fd);
}
if (ctlfd >= 0) {
close(ctlfd);
}
while ((acl_rule = QSIMPLEQ_FIRST(&acl_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&acl_list, entry);
g_free(acl_rule);
Expand Down

0 comments on commit eb3f45c

Please sign in to comment.