From 4eaf14e1e3f07445b88b7775df12445cc8150d5f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Sep 2023 15:48:57 -0400 Subject: [PATCH] bgpd: Prevent use after free from coverity's perspective Prevent a use after free from coverity's perspective. A bgp node may have been freed. Signed-off-by: Donald Sharp --- bgpd/bgp_mplsvpn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 9b5d568636..00930dea6b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1179,12 +1179,13 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn, /* Process change. */ bgp_aggregate_increment(to_bgp, p, bpi, afi, safi); bgp_process(to_bgp, bn, afi, safi); - bgp_dest_unlock_node(bn); if (debug) zlog_debug("%s: ->%s: %pBD Found route, changed attr", __func__, to_bgp->name_pretty, bn); + bgp_dest_unlock_node(bn); + return bpi; }