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