mdadm/SOURCES/0138-Fix-memory-leak-in-file-mdadm.patch

35 lines
908 B
Diff
Raw Normal View History

2024-04-30 11:37:58 +00:00
From e62a561ee8b7157a2390eab215dcef6240bd7b03 Mon Sep 17 00:00:00 2001
From: Guanqin Miao <miaoguanqin@huawei.com>
Date: Mon, 24 Apr 2023 16:06:37 +0800
Subject: [PATCH 138/165] Fix memory leak in file mdadm
When we test mdadm with asan, we found some memory leaks in mdadm.c
We fix these memory leaks based on code logic.
Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
---
mdadm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mdadm.c b/mdadm.c
index e32598cb..22d1c53b 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1708,6 +1708,10 @@ int main(int argc, char *argv[])
autodetect();
break;
}
+ if (ss) {
+ ss->ss->free_super(ss);
+ free(ss);
+ }
if (locked)
cluster_release_dlmlock();
close_fd(&mdfd);
--
2.40.1