瀏覽代碼

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.
Andreas Kling 3 年之前
父節點
當前提交
f99af1bef0
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Kernel/Syscalls/read.cpp

+ 1 - 1
Kernel/Syscalls/read.cpp

@@ -12,7 +12,7 @@ namespace Kernel {
 
 
 using BlockFlags = Thread::FileBlocker::BlockFlags;
 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));
     auto description = TRY(fds.open_file_description(fd));
     if (!description->is_readable())
     if (!description->is_readable())