The bi->net pointer that is being unlocked had a commit
that removed the `bi->net = NULL;` recently. This code
was preventing a use after free crash being experienced
in other code paths. While commit
37e679629f9 was fixing
a different code path crash.
Make the parent->net pointer aware it may be locked/freed
from multiple places and to not NULL the pointer to it
unless we have actually freed the data.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
struct bgp_info *bi = (struct bgp_info *)e->parent;
if (bi->net)
- bgp_unlock_node((struct bgp_node *)bi->net);
+ bi->net = bgp_unlock_node((struct bgp_node *)bi->net);
bgp_info_unlock(e->parent);
e->parent = NULL;
}
/*
* bgp_unlock_node
*/
-static inline void bgp_unlock_node(struct bgp_node *node)
+static inline struct bgp_node *bgp_unlock_node(struct bgp_node *node)
{
- route_unlock_node(bgp_node_to_rnode(node));
+ return (struct bgp_node *)route_unlock_node(bgp_node_to_rnode(node));
}
/*