diff mbox series

[4/4] Fix memory leak in file mdadm

Message ID 20230424080637.2152893-5-miaoguanqin@huawei.com (mailing list archive)
State Mainlined, archived
Delegated to: Jes Sorensen
Headers show
Series Fix memory leak for Manage Assemble Kill mdadm | expand

Commit Message

Guanqin Miao April 24, 2023, 8:06 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(+)

Comments

Mariusz Tkaczyk Aug. 23, 2023, 1:51 p.m. UTC | #1
On Mon, 24 Apr 2023 16:06:37 +0800
Guanqin Miao <miaoguanqin@huawei.com> wrote:

> 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>
diff mbox series

Patch

diff --git a/mdadm.c b/mdadm.c
index 2296911d..409da62c 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);