mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 00:56:19 +00:00
bgpd: fix memory leak for evpn
If `hash_get()` returns NULL, the list created with `list_new()` is not be freed. Since `hash_get()` should not fail, we don't need `list_delete()` and other boring `XFREE()`s for its failure case. Just ignore returning value of `hash_get()` in these cases. Signed-off-by: anlan_cs <vic.lan@pica8.com>
This commit is contained in:
parent
46a3bfa695
commit
ac390ef8ac
@ -167,10 +167,7 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt)
|
||||
irt->vrfs = list_new();
|
||||
|
||||
/* Add to hash */
|
||||
if (!hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern)) {
|
||||
XFREE(MTYPE_BGP_EVPN_VRF_IMPORT_RT, irt);
|
||||
return NULL;
|
||||
}
|
||||
(void)hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern);
|
||||
|
||||
return irt;
|
||||
}
|
||||
@ -272,10 +269,7 @@ static struct irt_node *import_rt_new(struct bgp *bgp,
|
||||
irt->vnis = list_new();
|
||||
|
||||
/* Add to hash */
|
||||
if (!hash_get(bgp->import_rt_hash, irt, hash_alloc_intern)) {
|
||||
XFREE(MTYPE_BGP_EVPN_IMPORT_RT, irt);
|
||||
return NULL;
|
||||
}
|
||||
(void)hash_get(bgp->import_rt_hash, irt, hash_alloc_intern);
|
||||
|
||||
return irt;
|
||||
}
|
||||
@ -5336,10 +5330,7 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
|
||||
vpn->route_table = bgp_table_init(bgp, AFI_L2VPN, SAFI_EVPN);
|
||||
|
||||
/* Add to hash */
|
||||
if (!hash_get(bgp->vnihash, vpn, hash_alloc_intern)) {
|
||||
XFREE(MTYPE_BGP_EVPN, vpn);
|
||||
return NULL;
|
||||
}
|
||||
(void)hash_get(bgp->vnihash, vpn, hash_alloc_intern);
|
||||
|
||||
bgp_evpn_remote_ip_hash_init(vpn);
|
||||
bgp_evpn_link_to_vni_svi_hash(bgp, vpn);
|
||||
|
Loading…
Reference in New Issue
Block a user