[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176062915610.3343688.9268207114006804614.stgit@frogsfrogsfrogs>
Date: Thu, 16 Oct 2025 08:41:52 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: [PATCH 08/16] fuse2fs: free global_fs after a failed ext2fs_close
call
From: Darrick J. Wong <djwong@...nel.org>
If ext2fs_close fails for any reason, it won't free the ext2_filsys
object or any of the other things that hang off of it, like the io
managers and whatnot. Right now this results in a memory leak of
global_fs, which is mostly benign because we're nearly to the end of
main() anyway.
However, a future patch will move the ext2fs_close call to op_destroy
prior to introducing iomap support, which means that we won't close
the (O_EXCL) block device before returning from umount, which will cause
problems with fstests and the user expectation that block devices are
closed when umount(8) returns.
Therefore, free the context after a failed close.
Cc: <linux-ext4@...r.kernel.org> # v1.43.7
Fixes: 6ae16a6814f47c ("misc: clean up error handling for ext2fs_run_ext3_journal()")
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 4d92e1e818b1c4..0a862ea086cbde 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -4904,10 +4904,9 @@ int main(int argc, char *argv[])
fflush(orig_stderr);
}
if (global_fs) {
- err = ext2fs_close(global_fs);
+ err = ext2fs_close_free(&global_fs);
if (err)
com_err(argv[0], err, "while closing fs");
- global_fs = NULL;
}
if (fctx.lockfile) {
if (unlink(fctx.lockfile)) {
Powered by blists - more mailing lists