forked from Bananymous/banan-os
Kernel: Fix possible dead lock in Process::read()
This commit is contained in:
parent
b15deb420f
commit
77c83e5552
|
@ -201,10 +201,13 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<size_t> Process::read(int fd, void* buffer, size_t count)
|
BAN::ErrorOr<size_t> Process::read(int fd, void* buffer, size_t count)
|
||||||
{
|
{
|
||||||
m_lock.lock();
|
OpenFileDescription open_fd_copy;
|
||||||
TRY(validate_fd(fd));
|
|
||||||
auto open_fd_copy = open_file_description(fd);
|
{
|
||||||
m_lock.unlock();
|
LockGuard _(m_lock);
|
||||||
|
TRY(validate_fd(fd));
|
||||||
|
open_fd_copy = open_file_description(fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(open_fd_copy.flags & O_RDONLY))
|
if (!(open_fd_copy.flags & O_RDONLY))
|
||||||
return BAN::Error::from_errno(EBADF);
|
return BAN::Error::from_errno(EBADF);
|
||||||
|
|
Loading…
Reference in New Issue