]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: the unixfd IO manager shouldn't close its fd
authorDarrick J. Wong <djwong@kernel.org>
Tue, 7 Oct 2025 18:55:20 +0000 (11:55 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 17 Oct 2025 23:34:21 +0000 (16:34 -0700)
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: <linux-ext4@vger.kernel.org> # v1.43.2
Fixes: 4ccf9e4fe165cf ("libext2fs: add unixfd_io_manager")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
lib/ext2fs/unix_io.c

index 723a5c2474cdd5d0d3f3aed75c148ba31d009575..1456b4d4bbe212c0bc1cf9993c4d01a5195e80a5 100644 (file)
@@ -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);