diff mbox series

[ovs-dev,09/14] northd: Fix leak of dynamic string for fwd group ports.

Message ID 20201120001724.2424494-10-i.maximets@ovn.org
State Accepted
Headers show
Series Pack of fixes for memory leaks. | expand

Commit Message

Ilya Maximets Nov. 20, 2020, 12:17 a.m. UTC
'group_ports' never destroyed and re-created on each iteration.

CC: Manoj Sharma <manoj.sharma@nutanix.com>
Fixes: edb240081518 ("Forwarding group to load balance l2 traffic with liveness detection")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 northd/ovn-northd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 1d41aacc6..474333e68 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -6138,6 +6138,7 @@  build_fwd_group_lflows(struct ovn_datapath *od, struct hmap *lflows)
     if (!(!od->nbs || !od->nbs->n_forwarding_groups)) {
         struct ds match = DS_EMPTY_INITIALIZER;
         struct ds actions = DS_EMPTY_INITIALIZER;
+        struct ds group_ports = DS_EMPTY_INITIALIZER;
 
         for (int i = 0; i < od->nbs->n_forwarding_groups; ++i) {
             const struct nbrec_forwarding_group *fwd_group = NULL;
@@ -6171,7 +6172,7 @@  build_fwd_group_lflows(struct ovn_datapath *od, struct hmap *lflows)
             ds_put_format(&match, "eth.dst == %s", fwd_group->vmac);
 
             /* Create a comma separated string of child ports */
-            struct ds group_ports = DS_EMPTY_INITIALIZER;
+            ds_clear(&group_ports);
             if (fwd_group->liveness) {
                 ds_put_cstr(&group_ports, "liveness=\"true\",");
             }
@@ -6192,6 +6193,7 @@  build_fwd_group_lflows(struct ovn_datapath *od, struct hmap *lflows)
 
         ds_destroy(&match);
         ds_destroy(&actions);
+        ds_destroy(&group_ports);
     }
 }