From 46d725f76b4ae045f0930fe310dbbcf8d8280bb4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 28 May 2023 10:13:16 -0400 Subject: [PATCH] lib, zebra: Ensure that the ifp->node exists On removal, ensure that the ifp->node is set to a null pointer so that FRR does not use data after freed. In addition ensure that the ifp->node exists before attempting to free it. Signed-off-by: Donald Sharp --- lib/if.c | 1 + zebra/interface.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/if.c b/lib/if.c index 08d8918742..6f567861d1 100644 --- a/lib/if.c +++ b/lib/if.c @@ -1028,6 +1028,7 @@ void if_terminate(struct vrf *vrf) if (ifp->node) { ifp->node->info = NULL; route_unlock_node(ifp->node); + ifp->node = NULL; } if_delete(&ifp); } diff --git a/zebra/interface.c b/zebra/interface.c index 231ddc51db..ccf1a0a204 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -267,6 +267,9 @@ struct interface *if_link_per_ns(struct zebra_ns *ns, struct interface *ifp) /* Delete a VRF. This is called in vrf_terminate(). */ void if_unlink_per_ns(struct interface *ifp) { + if (!ifp->node) + return; + ifp->node->info = NULL; route_unlock_node(ifp->node); ifp->node = NULL; -- 2.39.5