Quellcode durchsuchen

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 vor 3 Jahren
Ursprung
Commit
f99af1bef0
1 geänderte Dateien mit 1 neuen und 1 gelöschten Zeilen
  1. 1 1
      Kernel/Syscalls/read.cpp

+ 1 - 1
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())