Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: Free nexthop_group #14550

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

Keelan10
Copy link
Contributor

ng was not properly freed, leading to a memory leak. The commit calls nexthop_group_delete to free memory associated with ng.

The ASan leak log for reference:

***********************************************************************************
Address Sanitizer Error detected in isis_topo1.test_isis_topo1/r5.asan.zebra.24308

=================================================================
==24308==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f4f47b43d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f4f4753c0a8 in qcalloc lib/memory.c:105
    #2 0x7f4f47559526 in nexthop_group_new lib/nexthop_group.c:270
    #3 0x562ded6a39d4 in zebra_add_import_table_entry zebra/redistribute.c:681
    #4 0x562ded787c35 in rib_link zebra/zebra_rib.c:3972
    #5 0x562ded787c35 in rib_addnode zebra/zebra_rib.c:3993
    #6 0x562ded787c35 in process_subq_early_route_add zebra/zebra_rib.c:2860
    #7 0x562ded787c35 in process_subq_early_route zebra/zebra_rib.c:3138
    #8 0x562ded787c35 in process_subq zebra/zebra_rib.c:3178
    #9 0x562ded787c35 in meta_queue_process zebra/zebra_rib.c:3228
    #10 0x7f4f475f7118 in work_queue_run lib/workqueue.c:266
    #11 0x7f4f475dc7f2 in event_call lib/event.c:1969
    #12 0x7f4f4751f347 in frr_run lib/libfrr.c:1213
    #13 0x562ded69e818 in main zebra/main.c:486
    #14 0x7f4f468ffc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 152 byte(s) in 1 object(s) allocated from:
    #0 0x7f4f47b43d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f4f4753c0a8 in qcalloc lib/memory.c:105
    #2 0x7f4f475510ad in nexthop_new lib/nexthop.c:376
    #3 0x7f4f475539c5 in nexthop_dup lib/nexthop.c:914
    #4 0x7f4f4755b27a in copy_nexthops lib/nexthop_group.c:444
    #5 0x562ded6a3a1c in zebra_add_import_table_entry zebra/redistribute.c:682
    #6 0x562ded787c35 in rib_link zebra/zebra_rib.c:3972
    #7 0x562ded787c35 in rib_addnode zebra/zebra_rib.c:3993
    #8 0x562ded787c35 in process_subq_early_route_add zebra/zebra_rib.c:2860
    #9 0x562ded787c35 in process_subq_early_route zebra/zebra_rib.c:3138
    #10 0x562ded787c35 in process_subq zebra/zebra_rib.c:3178
    #11 0x562ded787c35 in meta_queue_process zebra/zebra_rib.c:3228
    #12 0x7f4f475f7118 in work_queue_run lib/workqueue.c:266
    #13 0x7f4f475dc7f2 in event_call lib/event.c:1969
    #14 0x7f4f4751f347 in frr_run lib/libfrr.c:1213
    #15 0x562ded69e818 in main zebra/main.c:486
    #16 0x7f4f468ffc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 184 byte(s) leaked in 2 allocation(s).
***********************************************************************************

`ng` was not properly freed, leading to a memory leak.
The commit calls `nexthop_group_delete` to free memory associated with `ng`.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in isis_topo1.test_isis_topo1/r5.asan.zebra.24308

=================================================================
==24308==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f4f47b43d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7f4f4753c0a8 in qcalloc lib/memory.c:105
    FRRouting#2 0x7f4f47559526 in nexthop_group_new lib/nexthop_group.c:270
    FRRouting#3 0x562ded6a39d4 in zebra_add_import_table_entry zebra/redistribute.c:681
    FRRouting#4 0x562ded787c35 in rib_link zebra/zebra_rib.c:3972
    FRRouting#5 0x562ded787c35 in rib_addnode zebra/zebra_rib.c:3993
    FRRouting#6 0x562ded787c35 in process_subq_early_route_add zebra/zebra_rib.c:2860
    FRRouting#7 0x562ded787c35 in process_subq_early_route zebra/zebra_rib.c:3138
    FRRouting#8 0x562ded787c35 in process_subq zebra/zebra_rib.c:3178
    FRRouting#9 0x562ded787c35 in meta_queue_process zebra/zebra_rib.c:3228
    FRRouting#10 0x7f4f475f7118 in work_queue_run lib/workqueue.c:266
    FRRouting#11 0x7f4f475dc7f2 in event_call lib/event.c:1969
    FRRouting#12 0x7f4f4751f347 in frr_run lib/libfrr.c:1213
    FRRouting#13 0x562ded69e818 in main zebra/main.c:486
    FRRouting#14 0x7f4f468ffc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 152 byte(s) in 1 object(s) allocated from:
    #0 0x7f4f47b43d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7f4f4753c0a8 in qcalloc lib/memory.c:105
    FRRouting#2 0x7f4f475510ad in nexthop_new lib/nexthop.c:376
    FRRouting#3 0x7f4f475539c5 in nexthop_dup lib/nexthop.c:914
    FRRouting#4 0x7f4f4755b27a in copy_nexthops lib/nexthop_group.c:444
    FRRouting#5 0x562ded6a3a1c in zebra_add_import_table_entry zebra/redistribute.c:682
    FRRouting#6 0x562ded787c35 in rib_link zebra/zebra_rib.c:3972
    FRRouting#7 0x562ded787c35 in rib_addnode zebra/zebra_rib.c:3993
    FRRouting#8 0x562ded787c35 in process_subq_early_route_add zebra/zebra_rib.c:2860
    FRRouting#9 0x562ded787c35 in process_subq_early_route zebra/zebra_rib.c:3138
    FRRouting#10 0x562ded787c35 in process_subq zebra/zebra_rib.c:3178
    FRRouting#11 0x562ded787c35 in meta_queue_process zebra/zebra_rib.c:3228
    FRRouting#12 0x7f4f475f7118 in work_queue_run lib/workqueue.c:266
    FRRouting#13 0x7f4f475dc7f2 in event_call lib/event.c:1969
    FRRouting#14 0x7f4f4751f347 in frr_run lib/libfrr.c:1213
    FRRouting#15 0x562ded69e818 in main zebra/main.c:486
    FRRouting#16 0x7f4f468ffc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 184 byte(s) leaked in 2 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <[email protected]>
Copy link
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@donaldsharp
Copy link
Member

@Mergifyio backport stable/9.0

@mergify
Copy link

mergify bot commented Oct 10, 2023

backport stable/9.0

✅ Backports have been created

@donaldsharp donaldsharp merged commit 078bef3 into FRRouting:master Oct 10, 2023
80 checks passed
ton31337 added a commit that referenced this pull request Oct 11, 2023
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.

3 participants