From c1d8790623839dd0395a18e21a34a87f26cd2e7c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 22 Nov 2024 22:19:29 +0200 Subject: [PATCH] Kernel: Don't allow sending commands to halted xHCI --- kernel/kernel/USB/XHCI/Controller.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/kernel/USB/XHCI/Controller.cpp b/kernel/kernel/USB/XHCI/Controller.cpp index 4d4ccebdb3..8df50bdb68 100644 --- a/kernel/kernel/USB/XHCI/Controller.cpp +++ b/kernel/kernel/USB/XHCI/Controller.cpp @@ -404,6 +404,13 @@ namespace Kernel { LockGuard _(m_mutex); + auto& operational = operational_regs(); + if (operational.usbsts & XHCI::USBSTS::HCHalted) + { + dwarnln("Trying to send a command on a halted controller"); + return BAN::Error::from_errno(EFAULT); + } + auto& command_trb = reinterpret_cast(m_command_ring_region->vaddr())[m_command_enqueue]; command_trb.raw.dword0 = trb.raw.dword0; command_trb.raw.dword1 = trb.raw.dword1;