]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, zebra: Ensure that the ifp->node exists
authorDonald Sharp <sharpd@nvidia.com>
Sun, 28 May 2023 14:13:16 +0000 (10:13 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Sun, 28 May 2023 14:13:16 +0000 (10:13 -0400)
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 <sharpd@nvidia.com>
lib/if.c
zebra/interface.c

index 08d89187427319b7ac525f36a43c0e5ee7916f92..6f567861d19ca9d7d8de97eb46c5568438b2ab24 100644 (file)
--- 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);
        }
index 231ddc51dbec169052480665ab7648778a3b9761..ccf1a0a204b790416b75a2e7abafeb4ab3d87afe 100644 (file)
@@ -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;