diff mbox series

[4/4] Fix memory leak in file mdadm

Message ID 20230406114011.3297545-5-miaoguanqin@huawei.com (mailing list archive)
State Superseded, archived
Headers show
Series Fix memory leak for Manage Assemble Kill mdadm | expand

Commit Message

Guanqin Miao April 6, 2023, 11:40 a.m. UTC
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>
---
 mdadm.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/mdadm.c b/mdadm.c
index 4685ad6b..19d7916b 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1709,6 +1709,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);