mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Fix resource leaks for failing allocation
In case, something would fail during format initialization, return allocated memory.
This commit is contained in:
parent
12ac6f9f11
commit
ee54e43702
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user