From e8bfe4448c86aa504545a0e1933b9e68b184bc87 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Sun, 24 Aug 2025 20:06:14 +0700 Subject: [PATCH] Fix possible panic in device enumeration --- xhcid/src/xhci/irq_reactor.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xhcid/src/xhci/irq_reactor.rs b/xhcid/src/xhci/irq_reactor.rs index c551040450..d3c82f699f 100644 --- a/xhcid/src/xhci/irq_reactor.rs +++ b/xhcid/src/xhci/irq_reactor.rs @@ -333,7 +333,16 @@ impl IrqReactor { ); { let mut ports = self.hci.ports.lock().unwrap(); - let port = &mut ports[port_id.root_hub_port_index()]; + let root_port_index = port_id.root_hub_port_index(); + if root_port_index >= ports.len() { + warn!( + "Received out of bounds transmit device numeration request on root index {} at port {} [port len was: {}]", + root_port_index, port_id, ports.len() + ); + return; + } + + let port = &mut ports[root_port_index]; port.clear_csc(); } } else {