Skip to content

Commit 8d9df5c

Browse files
committed
bgpd: fix bgp_pbr_match memory leak
> Direct leak of 1144 byte(s) in 13 object(s) allocated from: > #0 0x7f3eedeb4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 > #1 0x7f3eed86f8dd in qcalloc lib/memory.c:105 > #2 0x55b32d236faf in bgp_pbr_match_alloc_intern bgpd/bgp_pbr.c:1074 > #3 0x7f3eed817d79 in hash_get lib/hash.c:147 > FRRouting#4 0x55b32d242d9a in bgp_pbr_policyroute_add_to_zebra_unit bgpd/bgp_pbr.c:2486 > FRRouting#5 0x55b32d244436 in bgp_pbr_policyroute_add_to_zebra bgpd/bgp_pbr.c:2672 > FRRouting#6 0x55b32d245a05 in bgp_pbr_handle_entry bgpd/bgp_pbr.c:2843 > FRRouting#7 0x55b32d246912 in bgp_pbr_update_entry bgpd/bgp_pbr.c:2939 > FRRouting#8 0x55b32d3c7472 in bgp_zebra_announce bgpd/bgp_zebra.c:1618 > FRRouting#9 0x55b32d26e5e7 in bgp_process_main_one bgpd/bgp_route.c:3691 > FRRouting#10 0x55b32d26f77d in process_subq_other_route bgpd/bgp_route.c:3856 > FRRouting#11 0x55b32d2701ff in process_subq bgpd/bgp_route.c:3955 > FRRouting#12 0x55b32d27029f in meta_queue_process bgpd/bgp_route.c:3980 > FRRouting#13 0x7f3eed99fdd8 in work_queue_run lib/workqueue.c:282 > FRRouting#14 0x7f3eed97798e in event_call lib/event.c:2011 > FRRouting#15 0x7f3eed842ff1 in frr_run lib/libfrr.c:1216 > FRRouting#16 0x55b32d0a1a15 in main bgpd/bgp_main.c:545 > FRRouting#17 0x7f3eed229d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Fixes: d114b0d ("bgpd: inject policy route entry from bgp into zebra pbr entries.") Signed-off-by: Louis Scalbert <[email protected]>
1 parent 520518c commit 8d9df5c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bgpd/bgp_pbr.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,12 @@ static void bgp_pbr_match_entry_hash_free(void *arg)
984984
bgp_pbr_match_entry_free(bpme);
985985
}
986986

987-
static void bgp_pbr_match_free(void *arg)
987+
static void bgp_pbr_match_free(struct bgp_pbr_match *bpm)
988+
{
989+
XFREE(MTYPE_PBR_MATCH, bpm);
990+
}
991+
992+
static void bgp_pbr_match_hash_free(void *arg)
988993
{
989994
struct bgp_pbr_match *bpm;
990995

@@ -1009,7 +1014,7 @@ static void bgp_pbr_match_free(void *arg)
10091014
}
10101015
hash_clean_and_free(&bpm->entry_hash, NULL);
10111016

1012-
XFREE(MTYPE_PBR_MATCH, bpm);
1017+
bgp_pbr_match_free(bpm);
10131018
}
10141019

10151020
static void *bgp_pbr_match_alloc_intern(void *arg)
@@ -1377,7 +1382,7 @@ struct bgp_pbr_match *bgp_pbr_match_iptable_lookup(vrf_id_t vrf_id,
13771382

13781383
void bgp_pbr_cleanup(struct bgp *bgp)
13791384
{
1380-
hash_clean_and_free(&bgp->pbr_match_hash, bgp_pbr_match_free);
1385+
hash_clean_and_free(&bgp->pbr_match_hash, bgp_pbr_match_hash_free);
13811386
hash_clean_and_free(&bgp->pbr_rule_hash, bgp_pbr_rule_free);
13821387
hash_clean_and_free(&bgp->pbr_action_hash, bgp_pbr_action_free);
13831388

@@ -1706,6 +1711,7 @@ static void bgp_pbr_flush_entry(struct bgp *bgp, struct bgp_pbr_action *bpa,
17061711
bpm->action = NULL;
17071712
}
17081713
hash_release(bgp->pbr_match_hash, bpm);
1714+
bgp_pbr_match_free(bpm);
17091715
/* XXX release pbr_match_action if not used
17101716
* note that drop does not need to call send_pbr_action
17111717
*/

0 commit comments

Comments
 (0)