!74 [sync] PR-70: btrfs-progs: corrupt-block: fix memory leak in debug_corrupt_sector()
From: @openeuler-sync-bot Reviewed-by: @swf504 Signed-off-by: @swf504
This commit is contained in:
commit
0db2d8c674
@ -0,0 +1,56 @@
|
||||
From fd5a80e5bfb472c31eeab4caa4f4907b803b1b60 Mon Sep 17 00:00:00 2001
|
||||
From: Qu Wenruo <wqu@suse.com>
|
||||
Date: Fri, 6 Sep 2024 12:30:45 +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 <josef@toxicpanda.com>
|
||||
Signed-off-by: Qu Wenruo <wqu@suse.com>
|
||||
Signed-off-by: David Sterba <dsterba@suse.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: btrfs-progs
|
||||
Version: 6.6.3
|
||||
Release: 12
|
||||
Release: 13
|
||||
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
|
||||
@ -18,6 +18,7 @@ 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-convert-for-ext2-fix-possible-tree-check.patch
|
||||
Patch0012: 0012-btrfs-progs-convert-insert-a-dummy-inode-item-before.patch
|
||||
Patch0013: 0013-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
|
||||
@ -83,6 +84,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir
|
||||
%{_mandir}/man8/*.gz
|
||||
|
||||
%changelog
|
||||
* Fri Sep 6 2024 cenhuilin <cenhuilin@kylinos.cn> - 6.6.3-13
|
||||
- btrfs-progs: corrupt-block: fix memory leak in debug_corrupt_sector()
|
||||
|
||||
* Tue Sep 3 2024 liuh <liuhuan01@kylinos.cn> - 6.6.3-12
|
||||
- btrfs-progs: convert: insert a dummy inode item before inode ref for ext2/4
|
||||
- btrfs-progs: convert: for ext2, fix possible tree-checker error when converting a large fs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user