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 <wangyunjian@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
wyjwang authored and blp committed May 31, 2017
1 parent bc75e42 commit 24455f3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ofproto/netflow.c
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 24455f3

Please sign in to comment.