Kernel: Fix possible dead lock in Process::read()

This commit is contained in:
Bananymous 2023-04-23 14:46:18 +03:00
parent b15deb420f
commit 77c83e5552
1 changed files with 7 additions and 4 deletions

View File

@ -201,10 +201,13 @@ namespace Kernel
BAN::ErrorOr<size_t> Process::read(int fd, void* buffer, size_t count)
{
m_lock.lock();
OpenFileDescription open_fd_copy;
{
LockGuard _(m_lock);
TRY(validate_fd(fd));
auto open_fd_copy = open_file_description(fd);
m_lock.unlock();
open_fd_copy = open_file_description(fd);
}
if (!(open_fd_copy.flags & O_RDONLY))
return BAN::Error::from_errno(EBADF);