[lvm-devel] [PATCH 2/3] read_adopt_file: release r when exiting abnormally
Wu Guanghao
wuguanghao3 at huawei.com
Mon Aug 30 07:13:41 UTC 2021
When exiting abnormally, r may not be released.At the same time, avoid freeing up other space,
set the default value of r to NULL
Signed-off-by: Wu Guanghao <wuguanghao3 at huawei.com>
---
daemons/lvmlockd/lvmlockd-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index fef9589b9..d4d7f106f 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -938,7 +938,7 @@ static int read_adopt_file(struct list_head *vg_lockd)
char lm_type_str[16];
char mode[8];
struct lockspace *ls = NULL, *ls2;
- struct resource *r;
+ struct resource *r = NULL;
FILE *fp;
if (MAX_ARGS != 64 || MAX_NAME != 64)
@@ -1012,6 +1012,7 @@ static int read_adopt_file(struct list_head *vg_lockd)
}
}
+ free_resource(r);
fclose(fp);
return 0;
--
2.23.0
More information about the lvm-devel
mailing list