From 7fd98d149726fc69846bcfd5b3714a201912d3c3 Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Wed, 30 Sep 2020 12:03:06 -0700 Subject: [PATCH] zebra: fix double clearing of zif->es_info.es This problem was accidentally introduced as a part of another fixup - [ commit e378f5020d1af1aee587659e5602ee8c07eb05f4 (anuradhak/mh-misc-fixes, mh-misc-fixes) Author: Anuradha Karuppiah Date: Tue Sep 15 16:50:14 2020 -0700 zebra: fix use of freed es during zebra shutdown ] zif->es_info.es is cleared as a part of zebra_evpn_es_local_info_clear so it cannot be passed around as a pointer from zebra_evpn_local_es_update/del. Because of this bug removing ES from an interface resulted in a zebra crash. Signed-off-by: Anuradha Karuppiah --- zebra/zebra_evpn_mh.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index 7b397df384..dc8a4145c5 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -808,6 +808,7 @@ void zebra_evpn_if_init(struct zebra_if *zif) void zebra_evpn_if_cleanup(struct zebra_if *zif) { vlanid_t vid; + struct zebra_evpn_es *es; if (!bf_is_inited(zif->vlan_bitmap)) return; @@ -819,8 +820,9 @@ void zebra_evpn_if_cleanup(struct zebra_if *zif) bf_free(zif->vlan_bitmap); /* Delete associated Ethernet Segment */ - if (zif->es_info.es) - zebra_evpn_local_es_del(&zif->es_info.es); + es = zif->es_info.es; + if (es) + zebra_evpn_local_es_del(&es); } /***************************************************************************** @@ -1448,7 +1450,7 @@ static int zebra_evpn_local_es_update(struct zebra_if *zif, uint32_t lid, if (!lid || is_zero_mac(sysmac)) { /* if in ES is attached to zif delete it */ if (old_es) - zebra_evpn_local_es_del(&zif->es_info.es); + zebra_evpn_local_es_del(&old_es); return 0; } @@ -1473,7 +1475,7 @@ static int zebra_evpn_local_es_update(struct zebra_if *zif, uint32_t lid, /* release the old_es against the zif */ if (old_es) - zebra_evpn_local_es_del(&zif->es_info.es); + zebra_evpn_local_es_del(&old_es); es = zebra_evpn_es_find(&esi); if (es) { -- 2.39.5