vswitchd: Fix more memory leaks.
authorBen Pfaff <blp@nicira.com>
Wed, 14 Jan 2009 01:03:01 +0000 (17:03 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 14 Jan 2009 01:03:01 +0000 (17:03 -0800)
vswitchd/bridge.c

index 510f6404f03c8258470ebaa07f3386b666186729..6d06648e76a89873cadd0fb352756752645998f3 100644 (file)
@@ -679,13 +679,10 @@ static void
 bridge_destroy(struct bridge *br)
 {
     if (br) {
-        size_t i;
-
         while (br->n_ports > 0) {
             port_destroy(br->ports[br->n_ports - 1]);
         }
         list_remove(&br->node);
-        free(br->name);
         if (br->dp_idx >= 0) {
             int retval = dpif_del_dp(&mgmt_dpif, br->dp_idx, NULL);
             if (!retval || retval == ENOENT) {
@@ -701,9 +698,6 @@ bridge_destroy(struct bridge *br)
         }
         process_destroy(br->secchan);
         rconn_destroy(br->rconn);
-        for (i = 0; i < br->n_ports; i++) {
-            port_destroy(br->ports[i]);
-        }
         free(br->netflow_host);
         free(br->controller);
         svec_destroy(&br->secchan_opts);
@@ -713,6 +707,7 @@ bridge_destroy(struct bridge *br)
         mac_learning_destroy(br->ml);
         port_array_destroy(&br->ifaces);
         free(br->ports);
+        free(br->name);
         free(br);
     }
 }
@@ -2466,14 +2461,15 @@ port_destroy(struct port *port)
             }
         }
 
+        while (port->n_ifaces > 0) {
+            iface_destroy(port->ifaces[port->n_ifaces - 1]);
+        }
+
         del = br->ports[port->port_idx] = br->ports[--br->n_ports];
         del->port_idx = port->port_idx;
 
-        for (i = 0; i < port->n_ifaces; i++) {
-            iface_destroy(port->ifaces[i]);
-        }
         free(port->ifaces);
-        free(port->trunks);
+        bitmap_free(port->trunks);
         free(port->name);
         free(port);
         bridge_flush(br);
@@ -2701,6 +2697,10 @@ mirror_destroy(struct mirror *m)
             br->ports[i]->dst_mirrors &= ~(MIRROR_MASK_C(1) << m->idx);
         }
 
+        svec_destroy(&m->src_ports);
+        svec_destroy(&m->dst_ports);
+        free(m->vlans);
+
         m->bridge->mirrors[m->idx] = NULL;
         free(m);