aboutsummaryrefslogtreecommitdiff
path: root/qemu-bridge-helper.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-06-10 17:20:25 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2014-06-27 10:39:10 +0200
commiteb3f45c5af26f5284b5f8dd7319714ca70676e50 (patch)
tree3d198bb077432c9f8ec335412a3467d031d53d37 /qemu-bridge-helper.c
parentff4873cb8c81db89668d8b56e19e57b852edb5f5 (diff)
downloadqemu-arm-eb3f45c5af26f5284b5f8dd7319714ca70676e50.tar.gz
qemu-bridge-helper: Fix fd leak in main()
initialize fd and ctlfd, and close them at the end Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'qemu-bridge-helper.c')
-rw-r--r--qemu-bridge-helper.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c
index 6a0974eb48..36eb3bcfd6 100644
--- a/qemu-bridge-helper.c
+++ b/qemu-bridge-helper.c
@@ -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;
@@ -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);