From: Chirag Shah Date: Tue, 27 Oct 2020 05:18:46 +0000 (-0700) Subject: bgpd: fix mem leak in router bgp import vrf check X-Git-Tag: frr-7.5~4^2~17 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=237b9cc523de31b2633cc80ebf39a6b9795db613;p=mirror%2Ffrr.git bgpd: fix mem leak in router bgp import vrf check ==916511== 18 bytes in 2 blocks are definitely lost in loss record 7 of 147 ==916511== at 0x483877F: malloc (vg_replace_malloc.c:307) ==916511== by 0x4BE0F0A: strdup (strdup.c:42) ==916511== by 0x48D66CE: qstrdup (memory.c:122) ==916511== by 0x1E6E31: bgp_vpn_leak_export (bgp_mplsvpn.c:2690) ==916511== by 0x28E892: bgp_router_create (bgp_nb_config.c:124) ==916511== by 0x48E05AB: nb_callback_create (northbound.c:869) ==916511== by 0x48E0FA2: nb_callback_configuration (northbound.c:1183) ==916511== by 0x48E13D0: nb_transaction_process (northbound.c:1308) ==916511== by 0x48E0137: nb_candidate_commit_apply (northbound.c:741) ==916511== by 0x48E024B: nb_candidate_commit (northbound.c:773) ==916511== by 0x48E6B21: nb_cli_classic_commit (northbound_cli.c:64) ==916511== by 0x48E757E: nb_cli_apply_changes (northbound_cli.c:281) Signed-off-by: Chirag Shah --- diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 5ef3cf736d..7c55dde91b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -2691,8 +2691,7 @@ void bgp_vpn_leak_export(struct bgp *from_bgp) idir = BGP_VPN_POLICY_DIR_FROMVPN; edir = BGP_VPN_POLICY_DIR_TOVPN; - export_name = (from_bgp->name ? XSTRDUP(MTYPE_TMP, from_bgp->name) - : XSTRDUP(MTYPE_TMP, VRF_DEFAULT_NAME)); + export_name = from_bgp->name ? from_bgp->name : VRF_DEFAULT_NAME; for (afi = 0; afi < AFI_MAX; ++afi) { /* vrf leak is for IPv4 and IPv6 Unicast only */