[lvm-devel] [PATCH 3/3] read_adopt_file: fix memory leak
Wu Guanghao
wuguanghao3 at huawei.com
Mon Aug 30 07:14:17 UTC 2021
When exiting abnormally, forget to release ls
Signed-off-by: Wu Guanghao <wuguanghao3 at huawei.com>
---
daemons/lvmlockd/lvmlockd-core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index d4d7f106f..71d708603 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -970,8 +970,10 @@ static int read_adopt_file(struct list_head *vg_lockd)
memcpy(ls->vg_uuid, vg_uuid, 64);
- if ((ls->lm_type = str_to_lm(lm_type_str)) < 0)
+ if ((ls->lm_type = str_to_lm(lm_type_str)) < 0) {
+ free(ls);
goto fail;
+ }
list_add(&ls->list, vg_lockd);
--
2.23.0
More information about the lvm-devel
mailing list