ovs-ofctl: Fix minor memory leaks.
[sliver-openvswitch.git] / utilities / ovs-ofctl.c
index 70af5bd..7df0a90 100644 (file)
@@ -447,6 +447,8 @@ fetch_switch_config(struct vconn *vconn, struct ofp_switch_config *config_)
 
     config = reply->data;
     *config_ = *config;
+
+    ofpbuf_delete(reply);
 }
 
 static void
@@ -831,12 +833,9 @@ monitor_vconn(struct vconn *vconn)
 {
     struct unixctl_server *server;
     bool exiting = false;
-    int error, fd;
-
-    /* Daemonization will close stderr but we really want to keep it, so make a
-     * copy. */
-    fd = dup(STDERR_FILENO);
+    int error;
 
+    daemon_save_fd(STDERR_FILENO);
     daemonize_start();
     error = unixctl_server_create(NULL, &server);
     if (error) {
@@ -845,9 +844,6 @@ monitor_vconn(struct vconn *vconn)
     unixctl_command_register("exit", "", 0, 0, ofctl_exit, &exiting);
     daemonize_complete();
 
-    /* Now get stderr back. */
-    dup2(fd, STDERR_FILENO);
-
     for (;;) {
         struct ofpbuf *b;
         int retval;
@@ -875,6 +871,8 @@ monitor_vconn(struct vconn *vconn)
         unixctl_server_wait(server);
         poll_block();
     }
+    vconn_close(vconn);
+    unixctl_server_destroy(server);
 }
 
 static void