From: Ben Pfaff Date: Wed, 14 Jan 2009 01:03:01 +0000 (-0800) Subject: vswitchd: Fix more memory leaks. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe3aeb971df258693c22b432c76004f77f3c76c0;p=openvswitch vswitchd: Fix more memory leaks. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 510f6404..6d06648e 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -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);