From 99b2c423a9951529625ace41a3dbc83a3eebb219 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sun, 28 Oct 2018 10:54:52 +0000 Subject: [PATCH] zebra: fix zebra router memleaks * Correctly set safi to prevent duplicate allocations * Free previously allocated table->info before overwriting it Signed-off-by: Quentin Young --- zebra/zebra_router.c | 1 + zebra/zebra_vrf.c | 1 + 2 files changed, 2 insertions(+) diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 99d96fd67..afe3c708a 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -96,6 +96,7 @@ struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf, zrt = XCALLOC(MTYPE_ZEBRA_NS, sizeof(*zrt)); zrt->tableid = tableid; zrt->afi = afi; + zrt->safi = safi; zrt->ns_id = zvrf->zns->ns_id; zrt->table = (afi == AFI_IP6) ? srcdest_table_init() : route_table_init(); diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index e98a53360..38b8b43d7 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -380,6 +380,7 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi, table->cleanup = zebra_rtable_node_cleanup; zvrf->table[afi][safi] = table; + XFREE(MTYPE_RIB_TABLE_INFO, table->info); info = XCALLOC(MTYPE_RIB_TABLE_INFO, sizeof(*info)); info->zvrf = zvrf; info->afi = afi; -- 2.39.5