]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix memory leak for community stuff
authorDonatas Abraitis <donatas@opensourcerouting.org>
Sat, 16 Jul 2022 13:26:13 +0000 (16:26 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Sat, 16 Jul 2022 13:41:31 +0000 (16:41 +0300)
Do not forget to cleanup after we are done:

==395247== 8,268 (32 direct, 8,236 indirect) bytes in 1 blocks are definitely lost in loss record 199 of 205
==395247==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==395247==    by 0x492EB8E: qcalloc (in /usr/local/lib/libfrr.so.0.0.0)
==395247==    by 0x490BB12: hash_get (in /usr/local/lib/libfrr.so.0.0.0)
==395247==    by 0x1FBF63: community_intern (in /usr/lib/frr/bgpd)
==395247==    by 0x1FC0C5: community_parse (in /usr/lib/frr/bgpd)
==395247==    by 0x1F0B66: bgp_attr_community (in /usr/lib/frr/bgpd)
==395247==    by 0x1F4185: bgp_attr_parse (in /usr/lib/frr/bgpd)
==395247==    by 0x26BC29: bgp_update_receive (in /usr/lib/frr/bgpd)
==395247==    by 0x26E887: bgp_process_packet (in /usr/lib/frr/bgpd)
==395247==    by 0x4985380: thread_call (in /usr/local/lib/libfrr.so.0.0.0)
==395247==    by 0x491D521: frr_run (in /usr/local/lib/libfrr.so.0.0.0)
==395247==    by 0x1EBEE8: main (in /usr/lib/frr/bgpd)

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_community.c

index 78cf9ea76c8fe2a6de544fa69147d4590ddc601a..9f6f337c8808f852ddfc91a9b4b0c120e82ee415 100644 (file)
@@ -914,8 +914,16 @@ void community_init(void)
                            "BGP Community Hash");
 }
 
+static void community_hash_free(void *data)
+{
+       struct community *com = data;
+
+       community_free(&com);
+}
+
 void community_finish(void)
 {
+       hash_clean(comhash, community_hash_free);
        hash_free(comhash);
        comhash = NULL;
 }