summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2012-02-24 00:24:37 +0000
committerPetr Rockai <prockai@redhat.com>2012-02-24 00:24:37 +0000
commitdc4a15bb69f6461dafdd55de7798733be68ce4f7 (patch)
tree588ef3bd4eb4da26a1d638c1f484d004537cd55a /daemons
parent2a11eea2e153366feb8fefb9a49f4cd3a395d15c (diff)
downloadlvm2-dc4a15bb69f6461dafdd55de7798733be68ce4f7.tar.gz
lvm2-dc4a15bb69f6461dafdd55de7798733be68ce4f7.tar.xz
lvm2-dc4a15bb69f6461dafdd55de7798733be68ce4f7.zip
Fix server-side leaks in lvmetad.
Diffstat (limited to 'daemons')
-rw-r--r--daemons/lvmetad/lvmetad-core.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 8795263e..6b384b2c 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -365,12 +365,14 @@ static response pv_lookup(lvmetad_state *s, request r)
if (!pvid) {
debug("pv_lookup: could not find device %" PRIu64 "\n", devt);
unlock_pvid_to_pvmeta(s);
+ dm_config_destroy(res.cft);
return daemon_reply_simple("failed", "reason = %s", "device not found", NULL);
}
pv = make_pv_node(s, pvid, res.cft, NULL, res.cft->root);
if (!pv) {
unlock_pvid_to_pvmeta(s);
+ dm_config_destroy(res.cft);
return daemon_reply_simple("failed", "reason = %s", "PV not found", NULL);
}
@@ -761,7 +763,7 @@ static response pv_found(lvmetad_state *s, request r)
const char *vgid = daemon_request_str(r, "metadata/id", NULL);
struct dm_config_node *pvmeta = dm_config_find_node(r.cft->root, "pvmeta");
uint64_t device;
- struct dm_config_tree *cft;
+ struct dm_config_tree *cft, *pvmeta_old = NULL;
const char *old;
const char *pvid_dup;
int complete = 0, orphan = 0;
@@ -778,14 +780,18 @@ static response pv_found(lvmetad_state *s, request r)
lock_pvid_to_pvmeta(s);
- if ((old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device))))
+ if ((old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device)))) {
+ pvmeta_old = dm_hash_lookup(s->pvid_to_pvmeta, old);
dm_hash_remove(s->pvid_to_pvmeta, old);
+ }
cft = dm_config_create();
cft->root = dm_config_clone_node(cft, pvmeta, 0);
pvid_dup = dm_config_find_str(cft->root, "pvmeta/id", NULL);
dm_hash_insert(s->pvid_to_pvmeta, pvid, cft);
dm_hash_insert_binary(s->device_to_pvid, &device, sizeof(device), (void*)pvid_dup);
+ if (pvmeta_old)
+ dm_config_destroy(pvmeta_old);
unlock_pvid_to_pvmeta(s);