1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Release allocated resources in error path

If composite_filter_create() fails, release filters.
This commit is contained in:
Zdenek Kabelac 2012-02-08 10:46:24 +00:00
parent 7b408a08ef
commit 12ac6f9f11
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.91 - Version 2.02.91 -
=================================== ===================================
Release allocated resources in error path for composite_filter_create().
Do not use lstat() results when failed in _rm_link(). Do not use lstat() results when failed in _rm_link().
Remove a "waiting for another thread" log message from dmeventd plugins. Remove a "waiting for another thread" log message from dmeventd plugins.

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -728,6 +728,7 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
unsigned nr_filt = 0; unsigned nr_filt = 0;
const struct dm_config_node *cn; const struct dm_config_node *cn;
struct dev_filter *filters[MAX_FILTERS]; struct dev_filter *filters[MAX_FILTERS];
struct dev_filter *composite;
memset(filters, 0, sizeof(filters)); memset(filters, 0, sizeof(filters));
@ -781,8 +782,16 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
} }
/* Only build a composite filter if we really need it. */ /* Only build a composite filter if we really need it. */
return (nr_filt == 1) ? if (nr_filt == 1)
filters[0] : composite_filter_create(nr_filt, filters); return filters[0];
if (!(composite = composite_filter_create(nr_filt, filters))) {
stack;
nr_filt++; /* compensate skip NULL */
goto err;
}
return composite;
err: err:
nr_filt--; /* skip NULL */ nr_filt--; /* skip NULL */
while (nr_filt-- > 0) while (nr_filt-- > 0)