bgpd: call init, term, copy LS attr admin_group#21289
Merged
Merged
Conversation
There's an admin group struct embedded in the BGP LS attr; it needs to be init'd and freed. Reported-by: Haruto Kimura (Stella) <harutokimura0608@gmail.com> Signed-off-by: Mark Stapp <mjs@cisco.com>
Greptile SummaryThis PR fixes three memory-management bugs for the
The fix is minimal and correct. All three lifecycle operations ( Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[bgp_ls_attr_alloc] -->|XCALLOC zeros memory| B[admin_group_init\next_admin_group]
B -->|bf_init allocates bitmap.data| C[attr ready for use]
D[bgp_ls_attr_free] -->|check attr != NULL| E[admin_group_term\next_admin_group]
E -->|bf_free releases bitmap.data| F[XFREE other fields]
F --> G[XFREE attr]
H[bgp_ls_attr_copy] -->|XCALLOC + memcpy| I[shallow copy\next_admin_group shares pointer]
I -->|memset ext_admin_group to 0| J[bitmap.data = NULL\nno longer shared]
J -->|admin_group_copy| K[bf_copy creates deep copy\nof bitmap.data]
K --> L[dst fully independent from src]
Reviews (2): Last reviewed commit: "bgpd: properly copy ls attr's admin_grou..." | Re-trigger Greptile |
the bgp_ls_attr_copy() function must make a separate copy of the embedded admin_group in the bgp_ls_attr. Signed-off-by: Mark Stapp <mjs@cisco.com>
Contributor
Author
|
@greptileai review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's an admin group struct embedded in the BGP LS attr; it needs to be init'd, freed, and copied properly.