summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Stapp <mjs@labn.net>2023-02-22 08:58:28 -0500
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-02-22 19:50:27 +0000
commite98fbcadb2e682248bd92bd212112f11aa69462a (patch)
tree31c386d07bb11bb3ba50084f3fbde2afa50ec7a9
parent2bea6210453f08329d70442b93a45953313f43b0 (diff)
bgpd: free rfapi callback object always
An rfapi timer callback is responsible for the memory in a context object, even in special-case exit paths. Always free that object. Signed-off-by: Mark Stapp <mjs@labn.net> (cherry picked from commit 870d3d2cb8e2fa6ff9329ec7126265d1e25a38ae)
-rw-r--r--bgpd/rfapi/rfapi_import.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 1dd623d3f3..e897cf6900 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -2344,8 +2344,7 @@ static void rfapiMonitorEncapDelete(struct bgp_path_info *vpn_bpi)
}
/*
- * quagga lib/thread.h says this must return int even though
- * it doesn't do anything with the return value
+ * Timer callback for withdraw
*/
static void rfapiWithdrawTimerVPN(struct thread *t)
{
@@ -2355,19 +2354,27 @@ static void rfapiWithdrawTimerVPN(struct thread *t)
const struct prefix *p;
struct rfapi_monitor_vpn *moved;
afi_t afi;
+ bool early_exit = false;
if (bgp == NULL) {
vnc_zlog_debug_verbose(
"%s: NULL BGP pointer, assume shutdown race condition!!!",
__func__);
- return;
+ early_exit = true;
}
- if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
+ if (bgp && CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
vnc_zlog_debug_verbose(
"%s: BGP delete in progress, assume shutdown race condition!!!",
__func__);
+ early_exit = true;
+ }
+
+ /* This callback is responsible for the withdraw object's memory */
+ if (early_exit) {
+ XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
return;
}
+
assert(wcb->node);
assert(bpi);
assert(wcb->import_table);