]> Git Repo - qemu.git/commitdiff
qemu-bridge-helper: Fix fd leak in main()
authorGonglei <[email protected]>
Tue, 10 Jun 2014 09:20:25 +0000 (17:20 +0800)
committerStefan Hajnoczi <[email protected]>
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 <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
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);
This page took 0.026618 seconds and 4 git commands to generate.