From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/3] btrfs-progs: tune: fix the missing close()
Date: Fri, 2 Feb 2024 11:29:20 +1030 [thread overview]
Message-ID: <aa82c7345596ca6109abc756fc1875a070639723.1706827356.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1706827356.git.wqu@suse.com>
[BUG]
In "btrfs tune" subcomammand, 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.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
tune/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tune/main.c b/tune/main.c
index 9dcb55952b59..0fbf37dd4800 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.43.0
next prev parent reply other threads:[~2024-02-02 0:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 0:59 [PATCH 0/3] btrfs-progs: hunt down the stray fd close causing race with udev scan Qu Wenruo
2024-02-02 0:59 ` [PATCH 1/3] btrfs-progs: rescue: properly close the fs for clear-ino-cache Qu Wenruo
2024-02-02 8:48 ` Anand Jain
2024-02-02 0:59 ` Qu Wenruo [this message]
2024-02-02 9:01 ` [PATCH 2/3] btrfs-progs: tune: fix the missing close() Anand Jain
2024-02-02 0:59 ` [PATCH 3/3] btrfs-progs: fix the stray fd close in open_ctree_fs_info() Qu Wenruo
2024-02-07 16:36 ` Anand Jain
2024-02-07 21:05 ` Qu Wenruo
2024-02-08 2:53 ` Anand Jain
2024-02-07 9:52 ` [PATCH 0/3] btrfs-progs: hunt down the stray fd close causing race with udev scan David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa82c7345596ca6109abc756fc1875a070639723.1706827356.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox