1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Fix memory leaks in toolcontext error path.

E.g.
 # vgscan
  Parse error at byte 2360 (line 54): expected a value
  Failed to load config file /etc/lvm/lvm.conf
You have a memory leak (not released memory pool):
 [0x818c788] library (12 bytes)

...
This commit is contained in:
Milan Broz 2009-06-15 11:56:31 +00:00
parent 2565a5e528
commit 38ddfe7be5
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.48 - Version 2.02.48 -
=============================== ===============================
Fix memory leaks in toolcontext error path.
Re-instate partial activation support in clustered mode. (2.02.40) Re-instate partial activation support in clustered mode. (2.02.40)
Allow metadata correction even when PVs are missing. Allow metadata correction even when PVs are missing.
Use 'lvm lvresize' instead of 'lvresize' in fsadm. Use 'lvm lvresize' instead of 'lvresize' in fsadm.

View File

@ -516,15 +516,15 @@ static void _destroy_tag_configs(struct cmd_context *cmd)
{ {
struct config_tree_list *cfl; struct config_tree_list *cfl;
dm_list_iterate_items(cfl, &cmd->config_files) {
destroy_config_tree(cfl->cft);
}
if (cmd->cft && cmd->cft->root) { if (cmd->cft && cmd->cft->root) {
destroy_config_tree(cmd->cft); destroy_config_tree(cmd->cft);
cmd->cft = NULL; cmd->cft = NULL;
} }
dm_list_iterate_items(cfl, &cmd->config_files) {
destroy_config_tree(cfl->cft);
}
dm_list_init(&cmd->config_files); dm_list_init(&cmd->config_files);
} }
@ -1110,6 +1110,14 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
return cmd; return cmd;
error: error:
_destroy_tag_configs(cmd);
dev_cache_exit();
if (cmd->filter)
cmd->filter->destroy(cmd->filter);
if (cmd->mem)
dm_pool_destroy(cmd->mem);
if (cmd->libmem)
dm_pool_destroy(cmd->libmem);
dm_free(cmd); dm_free(cmd);
return NULL; return NULL;
} }