diff mbox series

[ovs-dev,ovn] ovn-controller: Fix the memory leak in ref lflow handling.

Message ID 20200708141401.21993-1-numans@ovn.org
State Accepted
Headers show
Series [ovs-dev,ovn] ovn-controller: Fix the memory leak in ref lflow handling. | expand

Commit Message

Numan Siddique July 8, 2020, 2:14 p.m. UTC
From: Numan Siddique <numans@ovn.org>

Valgrind found this:

tests/testsuite.dir/129/valgrind.415:12:==415== 4 bytes in 1 blocks are definitely lost in loss record 2 of 126
tests/testsuite.dir/129/valgrind.415-13-==415==    at 0x4C29E63: malloc (vg_replace_malloc.c:309)
tests/testsuite.dir/129/valgrind.415-14-==415==    by 0x4CEC87: xmalloc (util.c:138)
tests/testsuite.dir/129/valgrind.415-15-==415==    by 0x4CECF4: xmemdup0 (util.c:168)
tests/testsuite.dir/129/valgrind.415-16-==415==    by 0x4118AF: lflow_resource_add (lflow.c:231)
tests/testsuite.dir/129/valgrind.415-17-==415==    by 0x412507: consider_logical_flow (lflow.c:670)
tests/testsuite.dir/129/valgrind.415-18-==415==    by 0x4148C2: add_logical_flows (lflow.c:303)
tests/testsuite.dir/129/valgrind.415-19-==415==    by 0x4148C2: lflow_run (lflow.c:858)
tests/testsuite.dir/129/valgrind.415-20-==415==    by 0x42A16C: en_flow_output_run (ovn-controller.c:1765)
tests/testsuite.dir/129/valgrind.415-21-==415==    by 0x43FFE0: engine_compute (inc-proc-eng.c:310)
tests/testsuite.dir/129/valgrind.415-22-==415==    by 0x43FFE0: engine_run_node (inc-proc-eng.c:352)
tests/testsuite.dir/129/valgrind.415-23-==415==    by 0x43FFE0: engine_run (inc-proc-eng.c:377)
tests/testsuite.dir/129/valgrind.415-24-==415==    by 0x40995E: main (ovn-controller.c:2425)

ref_name member of 'struct ref_lflow_node' was not freed when handling the
port binding/address set/port group changes in lflow.c

This patch fixes this issue.

Fixes: 8a2c19f26ffa("ovn-controller: Incremental processing for address-set changes.")
Reported-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
---
 controller/lflow.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Dumitru Ceara July 8, 2020, 3:13 p.m. UTC | #1
On 7/8/20 4:14 PM, numans@ovn.org wrote:
> From: Numan Siddique <numans@ovn.org>
> 
> Valgrind found this:
> 
> tests/testsuite.dir/129/valgrind.415:12:==415== 4 bytes in 1 blocks are definitely lost in loss record 2 of 126
> tests/testsuite.dir/129/valgrind.415-13-==415==    at 0x4C29E63: malloc (vg_replace_malloc.c:309)
> tests/testsuite.dir/129/valgrind.415-14-==415==    by 0x4CEC87: xmalloc (util.c:138)
> tests/testsuite.dir/129/valgrind.415-15-==415==    by 0x4CECF4: xmemdup0 (util.c:168)
> tests/testsuite.dir/129/valgrind.415-16-==415==    by 0x4118AF: lflow_resource_add (lflow.c:231)
> tests/testsuite.dir/129/valgrind.415-17-==415==    by 0x412507: consider_logical_flow (lflow.c:670)
> tests/testsuite.dir/129/valgrind.415-18-==415==    by 0x4148C2: add_logical_flows (lflow.c:303)
> tests/testsuite.dir/129/valgrind.415-19-==415==    by 0x4148C2: lflow_run (lflow.c:858)
> tests/testsuite.dir/129/valgrind.415-20-==415==    by 0x42A16C: en_flow_output_run (ovn-controller.c:1765)
> tests/testsuite.dir/129/valgrind.415-21-==415==    by 0x43FFE0: engine_compute (inc-proc-eng.c:310)
> tests/testsuite.dir/129/valgrind.415-22-==415==    by 0x43FFE0: engine_run_node (inc-proc-eng.c:352)
> tests/testsuite.dir/129/valgrind.415-23-==415==    by 0x43FFE0: engine_run (inc-proc-eng.c:377)
> tests/testsuite.dir/129/valgrind.415-24-==415==    by 0x40995E: main (ovn-controller.c:2425)
> 
> ref_name member of 'struct ref_lflow_node' was not freed when handling the
> port binding/address set/port group changes in lflow.c
> 
> This patch fixes this issue.
> 
> Fixes: 8a2c19f26ffa("ovn-controller: Incremental processing for address-set changes.")
> Reported-by: Dumitru Ceara <dceara@redhat.com>
> Signed-off-by: Numan Siddique <numans@ovn.org>
> ---
>  controller/lflow.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/controller/lflow.c b/controller/lflow.c
> index 545436159..b2f585727 100644
> --- a/controller/lflow.c
> +++ b/controller/lflow.c
> @@ -476,6 +476,7 @@ lflow_handle_changed_ref(enum ref_type ref_type, const char *ref_name,
>          ovs_list_remove(&lrln->ref_list);
>          free(lrln);
>      }
> +    free(rlfn->ref_name);
>      free(rlfn);
>  
>      dhcp_opts_destroy(&dhcp_opts);
> 

Looks good to me, thanks!

Acked-by: Dumitru Ceara <dceara@redhat.com>
Numan Siddique July 8, 2020, 4:58 p.m. UTC | #2
On Wed, Jul 8, 2020 at 8:44 PM Dumitru Ceara <dceara@redhat.com> wrote:

> On 7/8/20 4:14 PM, numans@ovn.org wrote:
> > From: Numan Siddique <numans@ovn.org>
> >
> > Valgrind found this:
> >
> > tests/testsuite.dir/129/valgrind.415:12:==415== 4 bytes in 1 blocks are
> definitely lost in loss record 2 of 126
> > tests/testsuite.dir/129/valgrind.415-13-==415==    at 0x4C29E63: malloc
> (vg_replace_malloc.c:309)
> > tests/testsuite.dir/129/valgrind.415-14-==415==    by 0x4CEC87: xmalloc
> (util.c:138)
> > tests/testsuite.dir/129/valgrind.415-15-==415==    by 0x4CECF4: xmemdup0
> (util.c:168)
> > tests/testsuite.dir/129/valgrind.415-16-==415==    by 0x4118AF:
> lflow_resource_add (lflow.c:231)
> > tests/testsuite.dir/129/valgrind.415-17-==415==    by 0x412507:
> consider_logical_flow (lflow.c:670)
> > tests/testsuite.dir/129/valgrind.415-18-==415==    by 0x4148C2:
> add_logical_flows (lflow.c:303)
> > tests/testsuite.dir/129/valgrind.415-19-==415==    by 0x4148C2:
> lflow_run (lflow.c:858)
> > tests/testsuite.dir/129/valgrind.415-20-==415==    by 0x42A16C:
> en_flow_output_run (ovn-controller.c:1765)
> > tests/testsuite.dir/129/valgrind.415-21-==415==    by 0x43FFE0:
> engine_compute (inc-proc-eng.c:310)
> > tests/testsuite.dir/129/valgrind.415-22-==415==    by 0x43FFE0:
> engine_run_node (inc-proc-eng.c:352)
> > tests/testsuite.dir/129/valgrind.415-23-==415==    by 0x43FFE0:
> engine_run (inc-proc-eng.c:377)
> > tests/testsuite.dir/129/valgrind.415-24-==415==    by 0x40995E: main
> (ovn-controller.c:2425)
> >
> > ref_name member of 'struct ref_lflow_node' was not freed when handling
> the
> > port binding/address set/port group changes in lflow.c
> >
> > This patch fixes this issue.
> >
> > Fixes: 8a2c19f26ffa("ovn-controller: Incremental processing for
> address-set changes.")
> > Reported-by: Dumitru Ceara <dceara@redhat.com>
> > Signed-off-by: Numan Siddique <numans@ovn.org>
> > ---
> >  controller/lflow.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/controller/lflow.c b/controller/lflow.c
> > index 545436159..b2f585727 100644
> > --- a/controller/lflow.c
> > +++ b/controller/lflow.c
> > @@ -476,6 +476,7 @@ lflow_handle_changed_ref(enum ref_type ref_type,
> const char *ref_name,
> >          ovs_list_remove(&lrln->ref_list);
> >          free(lrln);
> >      }
> > +    free(rlfn->ref_name);
> >      free(rlfn);
> >
> >      dhcp_opts_destroy(&dhcp_opts);
> >
>
> Looks good to me, thanks!
>
> Acked-by: Dumitru Ceara <dceara@redhat.com>
>

Thanks Dumitru.

I applied this patch to master, branch-20.06 and branch-20.03

Thanks
Numan


>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
diff mbox series

Patch

diff --git a/controller/lflow.c b/controller/lflow.c
index 545436159..b2f585727 100644
--- a/controller/lflow.c
+++ b/controller/lflow.c
@@ -476,6 +476,7 @@  lflow_handle_changed_ref(enum ref_type ref_type, const char *ref_name,
         ovs_list_remove(&lrln->ref_list);
         free(lrln);
     }
+    free(rlfn->ref_name);
     free(rlfn);
 
     dhcp_opts_destroy(&dhcp_opts);