Skip to content

Commit

Permalink
lflow.c: Fix memory leak of shash addr_sets_ref.
Browse files Browse the repository at this point in the history
Fix it by using shash_destroy_free_data() instead of shash_destroy().

Example of asan log of this memory leak:

Direct leak of 232 byte(s) in 29 object(s) allocated from:
    #0 0x534b0f in malloc (/home/hanzhou/src/ovn/_build_as/controller/ovn-controller+0x534b0f)
    ovn-org#1 0x73bd4d in xmalloc__ /home/hanzhou/src/ovs/_build/../lib/util.c:137:15
    ovn-org#2 0x73bd4d in xmalloc /home/hanzhou/src/ovs/_build/../lib/util.c:172:12
    ovn-org#3 0x638c49 in parse_constant_set /home/hanzhou/src/ovn/_build_as/../lib/expr.c:971:14
    ovn-org#4 0x64450d in expr_parse_primary /home/hanzhou/src/ovn/_build_as/../lib/expr.c:1390:44
    ovn-org#5 0x63aefc in expr_parse_not /home/hanzhou/src/ovn/_build_as/../lib/expr.c:1479:16
    ovn-org#6 0x63ac45 in expr_parse__ /home/hanzhou/src/ovn/_build_as/../lib/expr.c:1486:22
    ovn-org#7 0x63b500 in expr_parse /home/hanzhou/src/ovn/_build_as/../lib/expr.c:1535:34
    ovn-org#8 0x63b500 in expr_parse_string /home/hanzhou/src/ovn/_build_as/../lib/expr.c:1557:25
    ovn-org#9 0x598a56 in convert_match_to_expr /home/hanzhou/src/ovn/_build_as/../controller/lflow.c:1240:22
    ovn-org#10 0x591c07 in consider_logical_flow__ /home/hanzhou/src/ovn/_build_as/../controller/lflow.c:1407:16
    ovn-org#11 0x58d641 in add_logical_flows /home/hanzhou/src/ovn/_build_as/../controller/lflow.c:393:9
    ovn-org#12 0x58d641 in lflow_run /home/hanzhou/src/ovn/_build_as/../controller/lflow.c:2444:5
    ovn-org#13 0x5f57a3 in en_lflow_output_run /home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c:2449:5
    ovn-org#14 0x65bc04 in engine_recompute /home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:380:5
    ovn-org#15 0x65b2a3 in engine_run_node /home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:456:17
    ovn-org#16 0x65b2a3 in engine_run /home/hanzhou/src/ovn/_build_as/../lib/inc-proc-eng.c:493:9
    ovn-org#17 0x5ef9c1 in main /home/hanzhou/src/ovn/_build_as/../controller/ovn-controller.c
    ovn-org#18 0x7f82418691a1 in __libc_start_main (/lib64/libc.so.6+0x281a1)

Reported-by: Numan Siddique <numans@ovn.org>
Fixes: aa3e4e8 ("lflow: Track reference count of address sets when parsing lflows.")
Signed-off-by: Han Zhou <hzhou@ovn.org>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
hzhou8 authored and ovsrobot committed Feb 24, 2022
1 parent cf506a0 commit f5599b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion controller/lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ convert_match_to_expr(const struct sbrec_logical_flow *lflow,
*pg_addr_set_ref = (!sset_is_empty(&port_groups_ref) ||
!shash_is_empty(&addr_sets_ref));
}
shash_destroy(&addr_sets_ref);
shash_destroy_free_data(&addr_sets_ref);
sset_destroy(&port_groups_ref);

if (!error) {
Expand Down

0 comments on commit f5599b0

Please sign in to comment.