diff mbox series

[ovs-dev] ovn-controller.c: Fix memory leak in addr_sets_update.

Message ID 20220224032700.1961481-1-hzhou@ovn.org
State Accepted
Headers show
Series [ovs-dev] ovn-controller.c: Fix memory leak in addr_sets_update. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Han Zhou Feb. 24, 2022, 3:27 a.m. UTC
The asan log:
Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x534cb7 in calloc (/home/hanzhou/src/ovn/_build_as/controller/ovn-controller+0x534cb7)
    #1 0x73bf9e in xcalloc__ /home/hanzhou/src/ovs/_build/../lib/util.c:121:31
    #2 0x73bf9e in xzalloc__ /home/hanzhou/src/ovs/_build/../lib/util.c:131:12
    #3 0x73bf9e in xzalloc /home/hanzhou/src/ovs/_build/../lib/util.c:165:12
    #4 0x5f7629 in addr_sets_update /home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c:1484:21
    #5 0x5f7629 in addr_sets_sb_address_set_handler /home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c:1531:5
    #6 0x65b140 in engine_compute /home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:406:28
    #7 0x65b140 in engine_run_node /home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:468:14
    #8 0x65b140 in engine_run /home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:493:9
    #9 0x5ef9c1 in main /home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c
    #10 0x7f3092dda1a1 in __libc_start_main (/lib64/libc.so.6+0x281a1)

Reported-by: Numan Siddique <numans@ovn.org>
Fixes: 6a60154f9 ("ovn-controller: Handle addresses deletion in address set incrementally.")
Signed-off-by: Han Zhou <hzhou@ovn.org>
---
 controller/ovn-controller.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Han Zhou Feb. 24, 2022, 4:25 a.m. UTC | #1
On Wed, Feb 23, 2022 at 7:27 PM Han Zhou <hzhou@ovn.org> wrote:
>
> The asan log:
> Direct leak of 32 byte(s) in 1 object(s) allocated from:
>     #0 0x534cb7 in calloc
(/home/hanzhou/src/ovn/_build_as/controller/ovn-controller+0x534cb7)
>     #1 0x73bf9e in xcalloc__
/home/hanzhou/src/ovs/_build/../lib/util.c:121:31
>     #2 0x73bf9e in xzalloc__
/home/hanzhou/src/ovs/_build/../lib/util.c:131:12
>     #3 0x73bf9e in xzalloc
/home/hanzhou/src/ovs/_build/../lib/util.c:165:12
>     #4 0x5f7629 in addr_sets_update
/home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c:1484:21
>     #5 0x5f7629 in addr_sets_sb_address_set_handler
/home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c:1531:5
>     #6 0x65b140 in engine_compute
/home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:406:28
>     #7 0x65b140 in engine_run_node
/home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:468:14
>     #8 0x65b140 in engine_run
/home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:493:9
>     #9 0x5ef9c1 in main
/home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c
>     #10 0x7f3092dda1a1 in __libc_start_main (/lib64/libc.so.6+0x281a1)
>
> Reported-by: Numan Siddique <numans@ovn.org>
> Fixes: 6a60154f9 ("ovn-controller: Handle addresses deletion in address
set incrementally.")
> Signed-off-by: Han Zhou <hzhou@ovn.org>
> ---
>  controller/ovn-controller.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
> index cff9447e6..c09018243 100644
> --- a/controller/ovn-controller.c
> +++ b/controller/ovn-controller.c
> @@ -1493,6 +1493,7 @@ addr_sets_update(const struct
sbrec_address_set_table *address_set_table,
>                       * For example, ff::01 is changed to ff::00:01. */
>                      free(as_diff);
>                      expr_constant_set_destroy(cs_new);
> +                    free(cs_new);
>                      continue;
>                  }
>                  shash_add(updated, as->name, as_diff);
> --
> 2.30.2
>

I applied to main to fix the broken CI.

Thanks,
Han
diff mbox series

Patch

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index cff9447e6..c09018243 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -1493,6 +1493,7 @@  addr_sets_update(const struct sbrec_address_set_table *address_set_table,
                      * For example, ff::01 is changed to ff::00:01. */
                     free(as_diff);
                     expr_constant_set_destroy(cs_new);
+                    free(cs_new);
                     continue;
                 }
                 shash_add(updated, as->name, as_diff);