diff --git a/WHATS_NEW b/WHATS_NEW index 43c49d551..d19231d66 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.91 - =================================== + Fix resource leaks for failing allocation of formats (lvm1/2,pool). Release allocated resources in error path for composite_filter_create(). Do not use lstat() results when failed in _rm_link(). Remove a "waiting for another thread" log message from dmeventd plugins. diff --git a/lib/format1/format1.c b/lib/format1/format1.c index 9b9df0f81..629bb8390 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -587,11 +587,14 @@ struct format_type *init_format(struct cmd_context *cmd) if (!(fmt->labeller = lvm1_labeller_create(fmt))) { log_error("Couldn't create lvm1 label handler."); + dm_free(fmt); return NULL; } if (!(label_register_handler(FMT_LVM1_NAME, fmt->labeller))) { log_error("Couldn't register lvm1 label handler."); + fmt->labeller->ops->destroy(fmt->labeller); + dm_free(fmt); return NULL; } diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c index 6caa76ac8..5f0c3b6bf 100644 --- a/lib/format_pool/format_pool.c +++ b/lib/format_pool/format_pool.c @@ -1,6 +1,6 @@ /* * Copyright (C) 1997-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -298,11 +298,14 @@ struct format_type *init_format(struct cmd_context *cmd) if (!(fmt->labeller = pool_labeller_create(fmt))) { log_error("Couldn't create pool label handler."); + dm_free(fmt); return NULL; } if (!(label_register_handler(FMT_POOL_NAME, fmt->labeller))) { log_error("Couldn't register pool label handler."); + fmt->labeller->ops->destroy(fmt->labeller); + dm_free(fmt); return NULL; } diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index df3c870d7..2b73f872a 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -2362,14 +2362,13 @@ struct format_type *create_text_format(struct cmd_context *cmd) if (!(fmt->labeller = text_labeller_create(fmt))) { log_error("Couldn't create text label handler."); - dm_free(fmt); - return NULL; + goto err; } if (!(label_register_handler(FMT_TEXT_NAME, fmt->labeller))) { log_error("Couldn't register text label handler."); - dm_free(fmt); - return NULL; + fmt->labeller->ops->destroy(fmt->labeller); + goto err; } if ((cn = find_config_tree_node(cmd, "metadata/dirs"))) { @@ -2402,8 +2401,7 @@ struct format_type *create_text_format(struct cmd_context *cmd) return fmt; err: - _free_dirs(&mda_lists->dirs); + _text_destroy(fmt); - dm_free(fmt); return NULL; }