From d5eab772c52adcca1b02fe7c9cac36a40e74d29e Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Fri, 20 Nov 2020 01:17:13 +0100 Subject: [PATCH 05/16] actions: Fix leak of child ports in fwd group. 'child_port_list' is an array of pointers that should be freed too. Direct leak of 30 byte(s) in 6 object(s) allocated from: #0 0x501fff in malloc (/tests/ovstest+0x501fff) #1 0x6227e6 in xmalloc /lib/util.c:138:15 #2 0x6228b8 in xmemdup0 /lib/util.c:168:15 #3 0x8183d6 in parse_fwd_group_action /lib/actions.c:3374:30 #4 0x814b6e in parse_action /lib/actions.c:3610:9 #5 0x8139ef in parse_actions /lib/actions.c:3637:14 #6 0x8136a3 in ovnacts_parse /lib/actions.c:3672:9 #7 0x813c80 in ovnacts_parse_string /lib/actions.c:3699:5 #8 0x53a979 in test_parse_actions /tests/test-ovn.c:1372:21 #9 0x54e7a8 in ovs_cmdl_run_command__ /lib/command-line.c:247:17 #10 0x537c75 in test_ovn_main /tests/test-ovn.c:1630:5 #11 0x54e7a8 in ovs_cmdl_run_command__ /lib/command-line.c:247:17 #12 0x537359 in main /tests/ovstest.c:133:9 #13 0x7f06978f21a2 in __libc_start_main (/lib64/libc.so.6+0x271a2) CC: Manoj Sharma Fixes: edb240081518 ("Forwarding group to load balance l2 traffic with liveness detection") Acked-by: Dumitru Ceara Signed-off-by: Ilya Maximets Signed-off-by: Numan Siddique --- lib/actions.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/actions.c b/lib/actions.c index 015bcbc4d..0464c51a8 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -3375,6 +3375,9 @@ parse_fwd_group_action(struct action_context *ctx) lexer_syntax_error(ctx->lexer, "expecting logical switch port"); if (child_port_list) { + for (int i = 0; i < n_child_ports; i++) { + free(child_port_list[i]); + } free(child_port_list); } return; @@ -3480,6 +3483,9 @@ encode_FWD_GROUP(const struct ovnact_fwd_group *fwd_group, static void ovnact_fwd_group_free(struct ovnact_fwd_group *fwd_group) { + for (int i = 0; i < fwd_group->n_child_ports; i++) { + free(fwd_group->child_ports[i]); + } free(fwd_group->child_ports); } -- 2.28.0