]> sourceware.org Git - lvm2.git/commitdiff
cov: fix failing filter initialization
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 15 Oct 2018 13:17:07 +0000 (15:17 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 15 Oct 2018 15:49:44 +0000 (17:49 +0200)
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.

lib/commands/toolcontext.c

index fa87bccd7b9746be8b422e1a285ba82867b5d40f..9f005935582c6c78377cd716f467fb0efbe8416d 100644 (file)
@@ -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;
 
This page took 0.104124 seconds and 5 git commands to generate.