1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

Kernel: Fix race conditions processing async device requests

This commit is contained in:
Tom 2021-02-06 16:59:32 -07:00 committed by Andreas Kling
parent 8177f2474b
commit 5ccc3637e3
4 changed files with 23 additions and 41 deletions

View file

@ -78,9 +78,14 @@ public:
[[nodiscard]] RequestWaitResult wait(Time* = nullptr);
void do_start(Badge<Device>)
void do_start(ScopedSpinLock<SpinLock<u8>>&& requests_lock)
{
do_start();
if (is_completed_result(m_result))
return;
m_result = Started;
requests_lock.unlock();
start();
}
void complete(RequestResult result);
@ -137,17 +142,6 @@ private:
void sub_request_finished(AsyncDeviceRequest&);
void request_finished();
void do_start()
{
{
ScopedSpinLock lock(m_lock);
if (is_completed_result(m_result))
return;
m_result = Started;
}
start();
}
bool in_target_context(const UserOrKernelBuffer& buffer) const
{
if (buffer.is_kernel_buffer())