diff options
author | Sarita Patra <saritap@vmware.com> | 2021-01-12 12:57:33 +0100 |
---|---|---|
committer | Sarita Patra <saritap@vmware.com> | 2021-01-15 07:38:18 +0100 |
commit | 6cc30090b8337d75a3a17e82aa2aa7ad8a9a871e (patch) | |
tree | c867f0def0baeaeaac301d7dff0a3098ceb79002 /pimd/pim_jp_agg.c | |
parent | Merge pull request #7866 from kishorekunal01/fpm_dump_issue (diff) | |
download | frr-6cc30090b8337d75a3a17e82aa2aa7ad8a9a871e.tar.xz frr-6cc30090b8337d75a3a17e82aa2aa7ad8a9a871e.zip |
pimd: fix multiple memory leak
Memleak: pim_jp_agg_single_upstream_send(), static variable are not
released.
Signed-off-by: Sarita Patra <saritap@vmware.com>
Diffstat (limited to 'pimd/pim_jp_agg.c')
-rw-r--r-- | pimd/pim_jp_agg.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/pimd/pim_jp_agg.c b/pimd/pim_jp_agg.c index 5279a0085..d95d9dd25 100644 --- a/pimd/pim_jp_agg.c +++ b/pimd/pim_jp_agg.c @@ -360,11 +360,9 @@ void pim_jp_agg_switch_interface(struct pim_rpf *orpf, struct pim_rpf *nrpf, void pim_jp_agg_single_upstream_send(struct pim_rpf *rpf, struct pim_upstream *up, bool is_join) { - static struct list *groups = NULL; - static struct pim_jp_agg_group jag; - static struct pim_jp_sources js; - - static bool first = true; + struct list groups, sources; + struct pim_jp_agg_group jag; + struct pim_jp_sources js; /* skip JP upstream messages if source is directly connected */ if (!up || !rpf->source_nexthop.interface || @@ -373,19 +371,19 @@ void pim_jp_agg_single_upstream_send(struct pim_rpf *rpf, if_is_loopback_or_vrf(rpf->source_nexthop.interface)) return; - if (first) { - groups = list_new(); - jag.sources = list_new(); - - listnode_add(groups, &jag); - listnode_add(jag.sources, &js); + memset(&groups, 0, sizeof(groups)); + memset(&sources, 0, sizeof(sources)); + jag.sources = &sources; - first = false; - } + listnode_add(&groups, &jag); + listnode_add(jag.sources, &js); jag.group.s_addr = up->sg.grp.s_addr; js.up = up; js.is_join = is_join; - pim_joinprune_send(rpf, groups); + pim_joinprune_send(rpf, &groups); + + list_delete_all_node(jag.sources); + list_delete_all_node(&groups); } |