[PATCH 2/3] btrfs-progs: tune: fix the missing close()

Qu Wenruo
2024-02-02T00:59:43Z

[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