1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-09-09 17:44:26 +03:00

Fix error path for create_toolcontext

Never return unfinished toolcontext - since error path is hit on
various stages of initialization we cannot leave it partially uninitialized,
since we would need to spread many more test across the code for config_valid.
Instead return NULL and properly release udev library resources as well.
This commit is contained in:
Zdenek Kabelac
2012-03-12 14:15:04 +00:00
parent 2c2bb4a458
commit f6632c1ef4
3 changed files with 10 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
Version 2.02.96 - Version 2.02.96 -
================================ ================================
Fix error path for failing toolcontext creation.
Fix warn msg for thin pool chunk size and update man for chunksize (2.02.89). Fix warn msg for thin pool chunk size and update man for chunksize (2.02.89).
Version 2.02.95 - 6th March 2012 Version 2.02.95 - 6th March 2012

View File

@@ -1371,6 +1371,11 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
cmd->config_valid = 1; cmd->config_valid = 1;
out: out:
if (cmd->config_valid != 1) {
destroy_toolcontext(cmd);
cmd = NULL;
}
return cmd; return cmd;
} }

View File

@@ -1248,13 +1248,16 @@ struct cmd_context *init_lvm(void)
if (!udev_init_library_context()) if (!udev_init_library_context())
stack; stack;
if (!(cmd = create_toolcontext(0, NULL, 1, 0))) if (!(cmd = create_toolcontext(0, NULL, 1, 0))) {
udev_fin_library_context();
return_NULL; return_NULL;
}
_cmdline.arg_props = &_arg_props[0]; _cmdline.arg_props = &_arg_props[0];
if (stored_errno()) { if (stored_errno()) {
destroy_toolcontext(cmd); destroy_toolcontext(cmd);
udev_fin_library_context();
return_NULL; return_NULL;
} }