From 563f0c2b2de19737e62017d318a7f5cdbbf8c210 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 27 Jul 2018 09:54:39 -0400 Subject: [PATCH] lib: Modify route unlock code to return appropriate pointer 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 --- lib/table.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/table.h b/lib/table.h index a9d788b35a..f58a6025e2 100644 --- a/lib/table.h +++ b/lib/table.h @@ -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; } /* -- 2.39.5