!52 [sync] PR-51: btrfs-progs: tune: fix the missing close() of filesystem fd

From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
This commit is contained in:
openeuler-ci-bot 2024-07-05 02:52:37 +00:00 committed by Gitee
commit 7d25afa7b6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From ace7d241ccf2582e832c4c4a75eb6b638a0f543b Mon Sep 17 00:00:00 2001
From: Qu Wenruo <wqu@suse.com>
Date: Tue, 2 Jul 2024 10:51:55 +0800
Subject: [PATCH] btrfs-progs: tune: fix the missing close() of filesystem fd
[BUG]
In "btrfs tune" subcommand, we're using open_ctree_fd(), which
requires passing a valid fd, and the caller is responsible to properly
handling the lifespan of the fd.
But we just call close_ctree() and btrfs_close_all_devices(), without
closing the fd.
[FIX]
Just manually close the fd.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
tune/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tune/main.c b/tune/main.c
index 9dcb559..0fbf37d 100644
--- a/tune/main.c
+++ b/tune/main.c
@@ -535,6 +535,7 @@ out:
}
close_ctree(root);
btrfs_close_all_devices();
+ close(fd);
free_out:
return ret;
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: btrfs-progs
Version: 6.6.3
Release: 8
Release: 9
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
@ -13,6 +13,7 @@ Patch0004: 0004-btrfs-progs-scrub-status-only-report-limits-if-at-le.patch
Patch0005: 0005-btrfs-progs-fix-freeing-of-device-after-error-in-btr.patch
Patch0006: 0006-fix-double-free-on-error-in-read_raid56.patch
Patch0007: 0007-btrfs-progs-fi-show-canonicalize-path-when-using-blk.patch
Patch0008: 0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch
BuildRequires: python3-devel >= 3.4
BuildRequires: libacl-devel, e2fsprogs-devel, libblkid-devel, libuuid-devel, zlib-devel, libzstd-devel, lzo-devel, systemd-devel
@ -78,6 +79,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir
%{_mandir}/man8/*.gz
%changelog
* Tue Jul 2 2024 cenhuilin <cenhuilin@kylinos.cn> - 6.6.3-9
- btrfs-progs: tune: fix the missing close() of filesystem fd
* Mon Jul 1 2024 liuh <liuhuan01@kylinos.cn> - 6.6.3-8
- btrfs-progs: fi show: canonicalize path when using blkid and -d