summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-21 20:03:11 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-21 20:22:48 +0100
commitf99af1bef0068bc4309f741ace7f8028282da964 (patch)
treea38b05191ce2e902a3a5703b646654ada4cd6817
parent401c9415b43cfc6fed079c1496cb8f269d87ea80 (diff)
downloadserenity-f99af1bef0068bc4309f741ace7f8028282da964.zip
Kernel: Make sure OpenFileDescription is kept alive while read() blocks
It's not safe to store OpenFileDescription in a raw pointer when blocking, since another thread may decide to close the corresponding file descriptor.
-rw-r--r--Kernel/Syscalls/read.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp
index 2de85e5bbf..190a7fe8c5 100644
--- a/Kernel/Syscalls/read.cpp
+++ b/Kernel/Syscalls/read.cpp
@@ -12,7 +12,7 @@ namespace Kernel {
using BlockFlags = Thread::FileBlocker::BlockFlags;
-static ErrorOr<OpenFileDescription*> open_readable_file_description(Process::OpenFileDescriptions const& fds, int fd)
+static ErrorOr<NonnullRefPtr<OpenFileDescription>> open_readable_file_description(Process::OpenFileDescriptions const& fds, int fd)
{
auto description = TRY(fds.open_file_description(fd));
if (!description->is_readable())