summaryrefslogtreecommitdiff
path: root/bgpd/bgp_advertise.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-09-10 08:53:36 -0400
committerDonald Sharp <sharpd@nvidia.com>2023-09-10 12:14:00 -0400
commitec8a02af45d038976f8423c17079a74db9e1fc63 (patch)
tree26bdf85601ed91d80fba157b65f16ddeb96f7d19 /bgpd/bgp_advertise.c
parentbee4e27e78506638a32b0beac0bb1daad4d14a44 (diff)
bgpd: bgp_clear_adj_in|remove dest may be freed
dest will not be freed due to lock but coverity does not know that. Give it a hint. This change includes modifying bgp_dest_unlock_node to return the dest pointer so that we can determine if we should continue working on dest or not with an assert. Since this is lock based we should be ok. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bgpd/bgp_advertise.c')
-rw-r--r--bgpd/bgp_advertise.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index da7b496d65..c215611edf 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -188,11 +188,11 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
bgp_dest_lock_node(dest);
}
-void bgp_adj_in_remove(struct bgp_dest *dest, struct bgp_adj_in *bai)
+void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai)
{
bgp_attr_unintern(&bai->attr);
- BGP_ADJ_IN_DEL(dest, bai);
- bgp_dest_unlock_node(dest);
+ BGP_ADJ_IN_DEL(*dest, bai);
+ *dest = bgp_dest_unlock_node(*dest);
peer_unlock(bai->peer); /* adj_in peer reference */
XFREE(MTYPE_BGP_ADJ_IN, bai);
}
@@ -212,9 +212,11 @@ bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer,
adj_next = adj->next;
if (adj->peer == peer && adj->addpath_rx_id == addpath_id)
- bgp_adj_in_remove(dest, adj);
+ bgp_adj_in_remove(&dest, adj);
adj = adj_next;
+
+ assert(dest);
}
return true;