Skip to content

Commit

Permalink
netflow: Fix memory leak in netflow_unref.
Browse files Browse the repository at this point in the history
The memory leak was triggered each time on calling netflow_unref() with
containing netflow_flows. And flows need to be removed and destroyed.

Signed-off-by: Yunjian Wang <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
wyjwang authored and blp committed May 31, 2017
1 parent 964e01d commit cbee493
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ofproto/netflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ netflow_unref(struct netflow *nf)
atomic_count_dec(&netflow_count);
collectors_destroy(nf->collectors);
ofpbuf_uninit(&nf->packet);

struct netflow_flow *nf_flow, *next;
HMAP_FOR_EACH_SAFE (nf_flow, next, hmap_node, &nf->flows) {
hmap_remove(&nf->flows, &nf_flow->hmap_node);
free(nf_flow);
}
hmap_destroy(&nf->flows);

free(nf);
}
}
Expand Down

0 comments on commit cbee493

Please sign in to comment.