Skip to content

Commit

Permalink
Kernel: Fix lock state corruption in AHCIPORT::start_request
Browse files Browse the repository at this point in the history
This code was unlocking the lock directly, but the Locker is still
attached, causing the lock to be unlocked an extra time, hence
corrupting the internal lock state.

This is extra confusing though, as complete_current_request() runs
without a lock which also looks like a bug. But that's a task for
another day.
  • Loading branch information
bgianfo authored and awesomekling committed May 15, 2021
1 parent f982ef0 commit f3f5a22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Kernel/Storage/AHCIPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,15 @@ void AHCIPort::start_request(AsyncBlockDeviceRequest& request)
auto result = prepare_and_set_scatter_list(request);
if (result.has_value()) {
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Request failure.", representative_port_index());
m_lock.unlock();
locker.unlock();
complete_current_request(result.value());
return;
}

auto success = access_device(request.request_type(), request.block_index(), request.block_count());
if (!success) {
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Request failure.", representative_port_index());
m_lock.unlock();
locker.unlock();
complete_current_request(AsyncDeviceRequest::Failure);
return;
}
Expand Down

0 comments on commit f3f5a22

Please sign in to comment.