]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Modify route unlock code to return appropriate pointer
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 27 Jul 2018 13:54:39 +0000 (09:54 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 27 Jul 2018 13:54:39 +0000 (09:54 -0400)
Modify the unlock code for a route_node to return NULL on
pointer freed or to return the node itself again.

We'll need to go through the code and fix this pattern,
but this is a problem for another day.  Get this fix in
place and we can make it a low hanging problem to fix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/table.h

index a9d788b35a07d6970554a7e365ac43668afc0e28..f58a6025e2105083ad2afb2ad35f2be817d7d7bb 100644 (file)
@@ -233,13 +233,17 @@ static inline struct route_node *route_lock_node(struct route_node *node)
 }
 
 /* Unlock node. */
-static inline void route_unlock_node(struct route_node *node)
+static inline struct route_node *route_unlock_node(struct route_node *node)
 {
        assert(node->lock > 0);
        (*(unsigned *)&node->lock)--;
 
-       if (node->lock == 0)
+       if (node->lock == 0) {
                route_node_delete(node);
+               return NULL;
+       }
+
+       return node;
 }
 
 /*