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.
This commit is contained in:
Andreas Kling 2021-11-21 20:03:11 +01:00
parent 401c9415b4
commit f99af1bef0
Notes: sideshowbarker 2024-07-18 00:53:42 +09:00

View file

@ -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())