Skip to content

Commit

Permalink
dm cache: avoid calling policy destructor twice on error
Browse files Browse the repository at this point in the history
If the cache policy's config values are not able to be set we must
set the policy to NULL after destroying it in create_cache_policy()
so we don't attempt to destroy it a second time later.

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Heinz Mauelshagen authored and Alasdair G Kergon committed Mar 20, 2013
1 parent 617a0b8 commit b978440
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,8 +1763,11 @@ static int create_cache_policy(struct cache *cache, struct cache_args *ca,
}

r = set_config_values(cache->policy, ca->policy_argc, ca->policy_argv);
if (r)
if (r) {
*error = "Error setting cache policy's config values";
dm_cache_policy_destroy(cache->policy);
cache->policy = NULL;
}

return r;
}
Expand Down

0 comments on commit b978440

Please sign in to comment.