Kernel/Storage: Add device null check in AHCIPort::handle_interrupt()

Before attempting to remove the device while handling an AHCI port
interrupt, check if m_connected_device is even non-null.
This happened during my bare metal run and caused a kernel panic.
This commit is contained in:
Linus Groh 2022-01-26 19:22:28 +00:00
parent 371d49c0f6
commit d8fb3290d5

View file

@ -73,7 +73,7 @@ void AHCIPort::handle_interrupt()
}
if (m_interrupt_status.is_set(AHCI::PortInterruptFlag::PRC) && m_interrupt_status.is_set(AHCI::PortInterruptFlag::PC)) {
clear_sata_error_register();
if ((m_port_registers.ssts & 0xf) != 3) {
if ((m_port_registers.ssts & 0xf) != 3 && m_connected_device) {
m_connected_device->prepare_for_unplug();
StorageManagement::the().remove_device(*m_connected_device);
g_io_work->queue([this]() {