summaryrefslogtreecommitdiffstats
path: root/ospfd
diff options
context:
space:
mode:
authorKeelan10 <keelan.cannoo@icloud.com>2023-08-22 23:00:46 +0200
committerKeelan10 <keelan.cannoo@icloud.com>2023-09-05 10:54:33 +0200
commit35cf10a680bdcc758c473eac7e50049695a190dd (patch)
tree20f095f1669cbc63be8cd5a9c660d870b1092d82 /ospfd
parentMerge pull request #14340 from mjstapp/txqlen_info (diff)
downloadfrr-35cf10a680bdcc758c473eac7e50049695a190dd.tar.xz
frr-35cf10a680bdcc758c473eac7e50049695a190dd.zip
ospfd: fix area range memory leak
Addressed a memory leak in OSPF by fixing the improper deallocation of area range nodes when removed from the table. Introducing a new function, `ospf_range_table_node_destroy` for proper node cleanup, resolved the issue. The ASan leak log for reference: ``` Direct leak of 56 byte(s) in 2 object(s) allocated from: #0 0x7faf661d1d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) #1 0x7faf65bce1e9 in qcalloc lib/memory.c:105 #2 0x55a66e0b61cd in ospf_area_range_new ospfd/ospf_abr.c:43 #3 0x55a66e0b61cd in ospf_area_range_set ospfd/ospf_abr.c:195 #4 0x55a66e07f2eb in ospf_area_range ospfd/ospf_vty.c:631 #5 0x7faf65b51548 in cmd_execute_command_real lib/command.c:993 #6 0x7faf65b51f79 in cmd_execute_command_strict lib/command.c:1102 #7 0x7faf65b51fd8 in command_config_read_one_line lib/command.c:1262 #8 0x7faf65b522bf in config_from_file lib/command.c:1315 #9 0x7faf65c832df in vty_read_file lib/vty.c:2605 #10 0x7faf65c83409 in vty_read_config lib/vty.c:2851 #11 0x7faf65bb0341 in frr_config_read_in lib/libfrr.c:977 #12 0x7faf65c6cceb in event_call lib/event.c:1979 #13 0x7faf65bb1488 in frr_run lib/libfrr.c:1213 #14 0x55a66dfb28c4 in main ospfd/ospf_main.c:249 #15 0x7faf651c9c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 56 byte(s) leaked in 2 allocation(s). ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospfd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index aa3cadf99..e3ed4f2f3 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -935,6 +935,15 @@ static void ospf_finish_final(struct ospf *ospf)
XFREE(MTYPE_OSPF_TOP, ospf);
}
+static void ospf_range_table_node_destroy(route_table_delegate_t *delegate,
+ struct route_table *table, struct route_node *node)
+{
+ XFREE(MTYPE_OSPF_AREA_RANGE, node->info);
+ XFREE(MTYPE_ROUTE_NODE, node);
+}
+
+route_table_delegate_t ospf_range_table_delegate = {.create_node = route_node_create,
+ .destroy_node = ospf_range_table_node_destroy};
/* allocate new OSPF Area object */
struct ospf_area *ospf_area_new(struct ospf *ospf, struct in_addr area_id)
@@ -971,8 +980,8 @@ struct ospf_area *ospf_area_new(struct ospf *ospf, struct in_addr area_id)
ospf_opaque_type10_lsa_init(new);
new->oiflist = list_new();
- new->ranges = route_table_init();
- new->nssa_ranges = route_table_init();
+ new->ranges = route_table_init_with_delegate(&ospf_range_table_delegate);
+ new->nssa_ranges = route_table_init_with_delegate(&ospf_range_table_delegate);
if (area_id.s_addr == OSPF_AREA_BACKBONE)
ospf->backbone = new;