Skip to content

Commit

Permalink
ovsdb-server: Fix memleak when failing to read storage.
Browse files Browse the repository at this point in the history
Fixes: 1b1d2e6 ("ovsdb: Introduce experimental support for clustered databases.")
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
dceara authored and blp committed Jul 15, 2021
1 parent df55196 commit ab9a0b9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ovsdb/ovsdb-server.c
Expand Up @@ -635,8 +635,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. */
Expand All @@ -651,9 +649,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;
Expand All @@ -666,6 +661,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);

Expand Down

0 comments on commit ab9a0b9

Please sign in to comment.