[ovs-dev] [PATCH ovn 03/14] actions: Fix leak of child ports in fwd group.

Ilya Maximets i.maximets at ovn.org
Fri Nov 20 00:17:13 UTC 2020


'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 <manoj.sharma at nutanix.com>
Fixes: edb240081518 ("Forwarding group to load balance l2 traffic with liveness detection")
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
---
 lib/actions.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/actions.c b/lib/actions.c
index 6300fef2c..d98af0f91 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -3366,6 +3366,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;
@@ -3471,6 +3474,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.25.4



More information about the dev mailing list