Skip to content

Commit

Permalink
db-ctl-base: Fix memory leak of db commands.
Browse files Browse the repository at this point in the history
Variable "want_key" in function check_condition and variable "key"
in function set_column were not destroyed in exception branch.

This patch calls ovsdb_atom_destroy to release resources to avoid
memory leak.

Fixes: 79c1a00 ("db-ctl-base: Don't die in set_column() on error.")
Fixes: e09b3af ("db-ctl-base: Don't die in is_condition_satisfied() on error")
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Zengyuan Wang <wangzengyuan@huawei.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
Zengyuan Wang authored and igsilya committed Oct 18, 2023
1 parent 7fb2197 commit 48fa547
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/db-ctl-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ check_condition(const struct ovsdb_idl_table_class *table,
type.value.type = OVSDB_TYPE_VOID;
error = ovsdb_datum_from_string(&b, &type, value_string, symtab);
if (error) {
ovsdb_atom_destroy(&want_key, column->type.key.type);
goto out;
}

Expand Down Expand Up @@ -1368,6 +1369,7 @@ set_column(const struct ovsdb_idl_table_class *table,
error = ovsdb_atom_from_string(&value, NULL, &column->type.value,
value_string, symtab);
if (error) {
ovsdb_atom_destroy(&key, column->type.key.type);
goto out;
}

Expand Down

1 comment on commit 48fa547

@prettydong
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can catch the leak by asan with command
ovs-vsctl find bridge other_config:br_mode=1=

Please sign in to comment.