]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu-bridge-helper: Fix fd leak in main()
authorGonglei <arei.gonglei@huawei.com>
Tue, 10 Jun 2014 09:20:25 +0000 (17:20 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 27 Jun 2014 08:39:10 +0000 (10:39 +0200)
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>
qemu-bridge-helper.c

index 6a0974eb4881a6d441e44713bd8c7072a845be7c..36eb3bcfd6625be5f66ad6c9d1f29f3439edc386 100644 (file)
@@ -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);