]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Fix several address sanitizer issues 3082/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 24 Sep 2018 19:12:36 +0000 (15:12 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 24 Sep 2018 19:12:36 +0000 (15:12 -0400)
This commit fixes two issues during pim shutdown.

1) The rp_info structure was being freed before the
outgoing notifications that depended on it's information
was sent out as part of shutdown.

2) The pim->upstream_list shutdown involved iterating
over the list via ALL_LIST_ELEMENTS.  This typically
is enough but pim will auto delete child nodes as well
as itself when it goes away and they depend on it.  As such
the node and nnode could possibly already have been freed.
So change the way we look at all the data in the upstream_list

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_instance.c
pimd/pim_upstream.c

index bf8d05d1e117671e1cb946a9bcd53bf193089d40..c592a2c047fbc7e910ed716919c7ae3f1b79494f 100644 (file)
@@ -44,10 +44,10 @@ static void pim_instance_terminate(struct pim_instance *pim)
        if (pim->static_routes)
                list_delete_and_null(&pim->static_routes);
 
-       pim_rp_free(pim);
-
        pim_upstream_terminate(pim);
 
+       pim_rp_free(pim);
+
        /* Traverse and cleanup rpf_hash */
        if (pim->rpf_hash) {
                hash_clean(pim->rpf_hash, (void *)pim_rp_list_hash_clean);
index 0728c9490ba565d75233169d3337faa697a213f4..4adfde677582f3ed3aaf5b389514c4f74b6604ed 100644 (file)
@@ -1534,12 +1534,13 @@ unsigned int pim_upstream_hash_key(void *arg)
 
 void pim_upstream_terminate(struct pim_instance *pim)
 {
-       struct listnode *node, *nnode;
        struct pim_upstream *up;
 
        if (pim->upstream_list) {
-               for (ALL_LIST_ELEMENTS(pim->upstream_list, node, nnode, up))
+               while (pim->upstream_list->count) {
+                       up = listnode_head(pim->upstream_list);
                        pim_upstream_del(pim, up, __PRETTY_FUNCTION__);
+               }
 
                list_delete_and_null(&pim->upstream_list);
        }