Skip to content

Commit 65c4f64

Browse files
committed
tree: always allocate config file in nvme_read_config()
Even if there was an error when reading the config file we still should store the config file name, as it might used later on to update/write the config file. So parsing errors don't really matter, and we'll get notified for I/O errors on writing anyway. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 451b365 commit 65c4f64

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/nvme/tree.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ int nvme_read_config(nvme_root_t r, const char *config_file)
152152
return err;
153153
}
154154

155+
r->config_file = strdup(config_file);
156+
if (!r->config_file) {
157+
errno = ENOMEM;
158+
return err;
159+
}
155160
err = json_read_config(r, config_file);
156-
if (!err)
157-
r->config_file = strdup(config_file);
158161
/*
159162
* The json configuration file is optional,
160163
* so ignore errors when opening the file.

0 commit comments

Comments
 (0)