From: Zdenek Kabelac Date: Mon, 15 Oct 2018 13:17:07 +0000 (+0200) Subject: cov: fix failing filter initialization X-Git-Tag: v2_03_01~30 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=13c49033ede4bb57878361e5ae04c96d4930e9fa;p=lvm2.git 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. --- diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index fa87bccd7..9f0059355 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1167,7 +1167,7 @@ bad: */ 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) { 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; 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."); goto bad; } - cmd->filter = filter; + cmd->filter = filter = pfilter; cmd->full_filter = filter;