diff --git a/0036-fix-memory-leak-in-file-mdadm.patch b/0036-fix-memory-leak-in-file-mdadm.patch new file mode 100644 index 0000000000000000000000000000000000000000..81a6129a4e5001ba0db45398352e48933e3b2d54 --- /dev/null +++ b/0036-fix-memory-leak-in-file-mdadm.patch @@ -0,0 +1,34 @@ +From e62a561ee8b7157a2390eab215dcef6240bd7b03 Mon Sep 17 00:00:00 2001 +From: Guanqin Miao +Date: Mon, 24 Apr 2023 16:06:37 +0800 +Subject: 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 +Signed-off-by: Li Xiao Keng +Acked-by: Mariusz Tkaczyk +Signed-off-by: Jes Sorensen +--- + mdadm.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/mdadm.c b/mdadm.c +index 25a1abd..b78c53b 100644 +--- a/mdadm.c ++++ b/mdadm.c +@@ -1757,6 +1757,10 @@ int main(int argc, char *argv[]) + autodetect(); + break; + } ++ if (ss) { ++ ss->ss->free_super(ss); ++ free(ss); ++ } + if (locked) + cluster_release_dlmlock(); + if (mdfd > 0) +-- +2.27.0 + diff --git a/mdadm.spec b/mdadm.spec index 55f3e1c5fc8c2799204bc02b95c0c11d00103a79..bcbf24514b5b56bd53ad23e2f57c7c95388c949b 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,6 +1,6 @@ Name: mdadm Version: 4.1 -Release: 12 +Release: 13 Summary: The software RAID arrays user manage tools License: GPLv2+ URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/ @@ -45,6 +45,7 @@ Patch32: 0032-Fix-memory-leak-after-mdadm-detail.patch Patch33: 0033-mdadm-block-creation-with-long-names.patch Patch34: 0034-Fix-null-pointer-for-incremental-in-mdadm.patch Patch35: 0035-Fix-race-of-mdadm-add-and-mdadm-incremental.patch +Patch36: 0036-fix-memory-leak-in-file-mdadm.patch BuildRequires: systemd gcc binutils Requires(post): systemd coreutils @@ -110,6 +111,9 @@ install -d -m 710 %{buildroot}/var/run/mdadm/ %{_mandir}/man*/* %changelog +* Mon Jun 24 2024 zhangyaqi - 4.1-13 +- fix memory leak in file mdadm + * Thu Dec 14 2023 wuguanghao - 4.1-12 - Fix race of "mdadm --add" and "mdadm --incremental"