]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: free rfapi callback object always
authorMark Stapp <mjs@labn.net>
Wed, 22 Feb 2023 13:58:28 +0000 (08:58 -0500)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Wed, 22 Feb 2023 19:50:29 +0000 (19:50 +0000)
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)

bgpd/rfapi/rfapi_import.c

index 2aae0bc6167260596e3a08961fb3f40d9addbc4d..f8d950b8dbff7686641e25e96c40cc8896a315fa 100644 (file)
@@ -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);