diff --git a/0011-btrfs-progs-corrupt-block-fix-memory-leak-in-debug_c.patch b/0011-btrfs-progs-corrupt-block-fix-memory-leak-in-debug_c.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a4a00970fd090961b3c9e2e1e69c54aca1ba99e --- /dev/null +++ b/0011-btrfs-progs-corrupt-block-fix-memory-leak-in-debug_c.patch @@ -0,0 +1,56 @@ +From fd5a80e5bfb472c31eeab4caa4f4907b803b1b60 Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Wed, 28 Aug 2024 09:59:32 +0800 +Subject: [PATCH] btrfs-progs: corrupt-block: fix memory leak in debug_corrupt_sector(). + +ASAN build (make D=asan) detects a memory leak in +btrfs-corrupt-block inside debug_corrupt_sector(). + +This can be reproduced by fsck/013 test case. + +The cause is pretty simple, we just malloc a sector and forgot to free +it. + +Issue: #806 +Reviewed-by: Josef Bacik +Signed-off-by: Qu Wenruo +Signed-off-by: David Sterba +--- + btrfs-corrupt-block.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c +index 1245973..e883198 100644 +--- a/btrfs-corrupt-block.c ++++ b/btrfs-corrupt-block.c +@@ -70,7 +70,7 @@ static int debug_corrupt_sector(struct btrfs_root *root, u64 logical, int mirror + if (ret < 0) { + errno = -ret; + error("cannot read bytenr %llu: %m", logical); +- return ret; ++ goto out; + } + printf("corrupting %llu copy %d\n", logical, mirror_num); + memset(buf, 0, sectorsize); +@@ -78,7 +78,7 @@ static int debug_corrupt_sector(struct btrfs_root *root, u64 logical, int mirror + if (ret < 0) { + errno = -ret; + error("cannot write bytenr %llu: %m", logical); +- return ret; ++ goto out; + } + } + +@@ -90,7 +90,8 @@ static int debug_corrupt_sector(struct btrfs_root *root, u64 logical, int mirror + if (mirror_num > num_copies) + break; + } +- ++out: ++ free(buf); + return 0; + } + +-- +2.23.0 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index 70e9e7cc762cc13fd7250017577294f3c28eb282..e873b23afc182c45ea380d9b8e9aab56622b350a 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -1,6 +1,6 @@ Name: btrfs-progs Version: 6.6.3 -Release: 11 +Release: 12 Summary: btrfs userspace programs License: GPLv2 and GPL+ and LGPL-2.1+ and GPL-3.0+ and LGPL-2.1 and MIT URL: https://btrfs.wiki.kernel.org/index.php/Main_Page @@ -16,6 +16,7 @@ Patch0007: 0007-btrfs-progs-fi-show-canonicalize-path-when-using-blk.patch Patch0008: 0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch Patch0009: 0009-btrfs-progs-error-out-immediately-if-an-unknown-back.patch Patch0010: 0010-btrfs-progs-fix-the-conflicting-super-block-flags.patch +Patch0011: 0011-btrfs-progs-corrupt-block-fix-memory-leak-in-debug_c.patch BuildRequires: python3-devel >= 3.4 BuildRequires: libacl-devel, e2fsprogs-devel, libblkid-devel, libuuid-devel, zlib-devel, libzstd-devel, lzo-devel, systemd-devel @@ -81,6 +82,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir %{_mandir}/man8/*.gz %changelog +* Wed Aug 28 2024 cenhuilin - 6.6.3-12 +- btrfs-progs: corrupt-block: fix memory leak in debug_corrupt_sector() + * Tue Aug 27 2024 liuh - 6.6.3-11 - btrfs-progs: fix the conflicting super block flags