From 00e750b9e645f7a7fab9ce464419c72bd8535df0 Mon Sep 17 00:00:00 2001
From: wangjufeng <wangjufeng@huawei.com>
Date: Wed, 5 Feb 2020 13:39:39 +0800
Subject: [PATCH] lvmetad: fix heap memory leak

When lvmetad make reponse for clent request, it should add all
new chunk for the dm_config_tree of reponse, not the cft of
global s->vgid_to_metadata, or, it will keep malloc new chunk
for s->vgid_to_metadata, that will lead to RSS memory keep
growing.

Signed-off-by: wangjufeng <wangjufeng@huawei.com>
---
 daemons/lvmetad/lvmetad-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index ef43b47..659d85c 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -730,7 +730,7 @@ static response vg_lookup(lvmetad_state *s, request r)
 	if (!(res.cft->root = n = dm_config_create_node(res.cft, "response")))
 		goto nomem_un;
 
-	if (!(n->v = dm_config_create_value(cft)))
+	if (!(n->v = dm_config_create_value(res.cft)))
 		goto nomem_un;
 
 	n->parent = res.cft->root;
-- 
1.8.3.1

