From c14eb7325c687768e3ba33507d022401e195776d Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 7 Oct 2025 11:55:20 -0700 Subject: [PATCH] libext2fs: the unixfd IO manager shouldn't close its fd The unixfd IO manager didn't create the fd that was passed in, so it should not close the fd when the io channel closes. Cc: # v1.43.2 Fixes: 4ccf9e4fe165cf ("libext2fs: add unixfd_io_manager") Signed-off-by: "Darrick J. Wong" --- lib/ext2fs/unix_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 723a5c24..1456b4d4 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -1061,7 +1061,7 @@ static errcode_t unix_open_channel(const char *name, int fd, cleanup: if (data) { - if (data->dev >= 0) + if (io->manager != unixfd_io_manager && data->dev >= 0) close(data->dev); if (data->cache) { free_cache(data); @@ -1147,7 +1147,7 @@ static errcode_t unix_close(io_channel channel) retval = flush_cached_blocks(channel, data, 0); #endif - if (close(data->dev) < 0) + if (channel->manager != unixfd_io_manager && close(data->dev) < 0) retval = errno; free_cache(data); free(data->cache); -- 2.47.3