1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cov: fix failing filter initialization

When persistent_filter_create() fails, the existing passed filter
should be preserved, so it could be properly deleted on
error path - so new pfilter is assigned instead.
This commit is contained in:
Zdenek Kabelac 2018-10-15 15:17:07 +02:00
parent a7298810d1
commit 13c49033ed

View File

@ -1167,7 +1167,7 @@ bad:
*/ */
int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache) int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
{ {
struct dev_filter *filter = NULL, *filter_components[2] = {0}; struct dev_filter *pfilter, *filter = NULL, *filter_components[2] = {0};
if (!cmd->initialized.connections) { if (!cmd->initialized.connections) {
log_error(INTERNAL_ERROR "connections must be initialized before filters"); log_error(INTERNAL_ERROR "connections must be initialized before filters");
@ -1192,12 +1192,12 @@ int init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
filter = cmd->lvmetad_filter; filter = cmd->lvmetad_filter;
cmd->lvmetad_filter = NULL; cmd->lvmetad_filter = NULL;
if (!(filter = persistent_filter_create(cmd->dev_types, filter))) { if (!(pfilter = persistent_filter_create(cmd->dev_types, filter))) {
log_verbose("Failed to create persistent device filter."); log_verbose("Failed to create persistent device filter.");
goto bad; goto bad;
} }
cmd->filter = filter; cmd->filter = filter = pfilter;
cmd->full_filter = filter; cmd->full_filter = filter;