mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-28 02:50:41 +03:00
lib: fix init error handling
When setting up a toolcontext, the lib init function was detecting an error when there was none, and then it was returning an incompletely initialized cmd struct instead of NULL. The effect was that the lib would try to use the uninitialized cmd struct and segfault. This would happen if a non-fatal error occurred during cmd setup, e.g. user permission failed on lvmetad socket, causing cmd to fall back to scanning and not use lvmetad. The only real error condition is when create_toolcontext returns NULL. If cmd is returned, the lib can use it.
This commit is contained in:
parent
a6203657a0
commit
87d9406725
@ -1945,7 +1945,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
|
||||
_init_globals(cmd);
|
||||
|
||||
if (set_connections && !init_connections(cmd))
|
||||
return_0;
|
||||
goto_out;
|
||||
|
||||
if (set_filters && !init_filters(cmd, 1))
|
||||
goto_out;
|
||||
|
@ -49,9 +49,6 @@ static lvm_t _lvm_init(const char *system_dir)
|
||||
if (!cmd)
|
||||
return NULL;
|
||||
|
||||
if (stored_errno())
|
||||
return (lvm_t) cmd;
|
||||
|
||||
/*
|
||||
* FIXME: if an non memory error occured, return the cmd (maybe some
|
||||
* cleanup needed).
|
||||
|
Loading…
x
Reference in New Issue
Block a user