diff options
author | Dumitru Ceara <dceara@redhat.com> | 2021-07-14 09:21:19 +0200 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2021-07-15 11:54:15 -0700 |
commit | c161412649beeec24a014a4266beb0036ded3b68 (patch) | |
tree | 131b70ceec0338d15849c21e90eaaf32a1dabc91 | |
parent | e58535f27d563634c0c3bceb826439256de102a1 (diff) | |
download | openvswitch-c161412649beeec24a014a4266beb0036ded3b68.tar.gz |
ovsdb-server: Fix memleak when failing to read storage.
Fixes: 1b1d2e6daa56 ("ovsdb: Introduce experimental support for clustered databases.")
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | ovsdb/ovsdb-server.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index c7b803bbd..7c5df73b2 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -625,8 +625,6 @@ add_db(struct server_config *config, struct db *db) static struct ovsdb_error * OVS_WARN_UNUSED_RESULT open_db(struct server_config *config, const char *filename) { - struct db *db; - /* If we know that the file is already open, return a good error message. * Otherwise, if the file is open, we'll fail later on with a harder to * interpret file locking error. */ @@ -641,9 +639,6 @@ open_db(struct server_config *config, const char *filename) return error; } - db = xzalloc(sizeof *db); - db->filename = xstrdup(filename); - struct ovsdb_schema *schema; if (ovsdb_storage_is_clustered(storage)) { schema = NULL; @@ -656,6 +651,9 @@ open_db(struct server_config *config, const char *filename) } ovs_assert(schema && !txn_json); } + + struct db *db = xzalloc(sizeof *db); + db->filename = xstrdup(filename); db->db = ovsdb_create(schema, storage); ovsdb_jsonrpc_server_add_db(config->jsonrpc, db->db); |