From 46e9a93eea00f303a693126bf28ac9db284090f1 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 15 Jul 2025 18:27:58 -0400 Subject: [PATCH] kernel/fs: Remove special handling for O_DISCONNECTED in remove_fd(). This method is used in close_fd_index(), the normal path for close() operations to go through. So, if a close() had been called on a disconnected FD, before this commit we would just leak it. This change means that close_fd() and put_fd() are called on disconnected FDs being close()d. That's the same set of operations that deleting an I/O context does, though, so this should hopefully not cause any problems. --- src/system/kernel/fs/fd.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp index 0cfc62b63c..94d81d1485 100644 --- a/src/system/kernel/fs/fd.cpp +++ b/src/system/kernel/fs/fd.cpp @@ -324,7 +324,6 @@ remove_fd(struct io_context* context, int fd) descriptor = context->fds[fd]; select_info* selectInfos = NULL; - bool disconnected = false; if (descriptor != NULL) { // fd is valid @@ -337,14 +336,12 @@ remove_fd(struct io_context* context, int fd) selectInfos = context->select_infos[fd]; context->select_infos[fd] = NULL; - - disconnected = (descriptor->open_mode & O_DISCONNECTED); } if (selectInfos != NULL) deselect_select_infos(descriptor, selectInfos, true); - return disconnected ? NULL : descriptor; + return descriptor; }