Skip to content

bgpd: fix memory leak in cluster_intern() - #20913

Merged
donaldsharp merged 1 commit into
FRRouting:masterfrom
enkechen-panw:bgp-cluster-mem
Feb 24, 2026
Merged

bgpd: fix memory leak in cluster_intern()#20913
donaldsharp merged 1 commit into
FRRouting:masterfrom
enkechen-panw:bgp-cluster-mem

Conversation

@enkechen-panw

Copy link
Copy Markdown
Contributor

Fixed memory leak in cluster_intern().

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
@greptile-apps

greptile-apps Bot commented Feb 24, 2026

Copy link
Copy Markdown

Greptile Summary

Fixed memory leak in cluster_intern() by adding cleanup logic when hash_get() returns an existing cluster entry.

  • Added check to free the input cluster parameter when it differs from the returned hash entry
  • Aligns cluster_intern() with the same pattern used by other intern functions (transit_intern, bgp_nhc_intern, srv6_vpn_intern)
  • The leak occurred when hash_get() found an existing cluster in the hash table but the newly allocated input cluster was not freed

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix correctly addresses a memory leak by following the established pattern used in other similar functions throughout the codebase. The change is minimal, well-contained, and logically sound.
  • No files require special attention

Important Files Changed

Filename Overview
bgpd/bgp_attr.c Fixed memory leak by freeing cluster parameter when hash_get returns existing entry

Last reviewed commit: 255a123

@donaldsharp
donaldsharp merged commit 5c67d31 into FRRouting:master Feb 24, 2026
24 checks passed
@donaldsharp

Copy link
Copy Markdown
Member

@Mergifyio backport dev/10.6 stable/10.5 stable/10.4

@mergify

mergify Bot commented Feb 24, 2026

Copy link
Copy Markdown

backport dev/10.6 stable/10.5 stable/10.4

βœ… Backports have been created

Details

donaldsharp added a commit that referenced this pull request Feb 24, 2026
bgpd: fix memory leak in cluster_intern() (backport #20913)
donaldsharp added a commit that referenced this pull request Feb 24, 2026
bgpd: fix memory leak in cluster_intern() (backport #20913)
donaldsharp added a commit that referenced this pull request Feb 24, 2026
bgpd: fix memory leak in cluster_intern() (backport #20913)
@enkechen-panw
enkechen-panw deleted the bgp-cluster-mem branch February 24, 2026 16:55
@mattiaswal mattiaswal mentioned this pull request Mar 18, 2026
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants