From 48fa547473614d13cb9f7a07d87d9de77ca2665a Mon Sep 17 00:00:00 2001 From: Zengyuan Wang Date: Tue, 17 Oct 2023 19:11:19 +0800 Subject: [PATCH] db-ctl-base: Fix memory leak of db commands. 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: 79c1a00fb5a5 ("db-ctl-base: Don't die in set_column() on error.") Fixes: e09b3af3e249 ("db-ctl-base: Don't die in is_condition_satisfied() on error") Acked-by: Simon Horman Signed-off-by: Zengyuan Wang Signed-off-by: Ilya Maximets --- lib/db-ctl-base.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 70745615886..28a9dbb60e0 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -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; } @@ -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; }