From 8177f2474b255d035d49a244f78cc3ef74559f9e Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 6 Feb 2021 11:53:40 -0700 Subject: [PATCH] Kernel: Fix race condition completing IDEChannel async request --- Kernel/Storage/IDEChannel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Storage/IDEChannel.cpp b/Kernel/Storage/IDEChannel.cpp index 6a7cbe694a..a59342fdb9 100644 --- a/Kernel/Storage/IDEChannel.cpp +++ b/Kernel/Storage/IDEChannel.cpp @@ -124,6 +124,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu // before Processor::deferred_call_queue returns! Processor::deferred_call_queue([this, result]() { dbgln_if(PATA_DEBUG, "IDEChannel::complete_current_request result: {}", (int)result); + ScopedSpinLock lock(m_request_lock); VERIFY(m_current_request); auto& request = *m_current_request; m_current_request = nullptr; @@ -132,6 +133,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu if (result == AsyncDeviceRequest::Success) { if (request.request_type() == AsyncBlockDeviceRequest::Read) { if (!request.write_to_buffer(request.buffer(), m_dma_buffer_page->paddr().offset(0xc0000000).as_ptr(), 512 * request.block_count())) { + lock.unlock(); request.complete(AsyncDeviceRequest::MemoryFault); return; } @@ -142,6 +144,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu } } + lock.unlock(); request.complete(result); }); }