From 21cf3d900cffc5776cd3f0b688d0d42452d0011c Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Tue, 7 Jul 2026 17:02:29 +0300 Subject: [PATCH] USB: eliminate panics in device_enumerator hotplug path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit device_enumerator.rs: - Line 31: panic!() on channel disconnect → graceful log+return (channel disconnect means xhcid is shutting down — graceful exit) - Line 70: panic!() on port not in disabled state → warn+continue (transient power state during USB 2.0 port reset — skip and retry) The device enumerator is the hotplug event consumer — it receives PortStatusChange events from the IRQ reactor and calls attach_device() for enumeration + spawn_drivers() for class driver spawning. These panic sites were the last remaining crash vectors in the hotplug path. --- drivers/usb/xhcid/src/xhci/device_enumerator.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/xhcid/src/xhci/device_enumerator.rs b/drivers/usb/xhcid/src/xhci/device_enumerator.rs index 8cd0ca3a3e..867575d404 100644 --- a/drivers/usb/xhcid/src/xhci/device_enumerator.rs +++ b/drivers/usb/xhcid/src/xhci/device_enumerator.rs @@ -28,7 +28,8 @@ impl DeviceEnumerator { let request = match self.request_queue.recv() { Ok(req) => req, Err(err) => { - panic!("Failed to received an enumeration request! error: {}", err) + log::error!("Device enumerator channel disconnected: {} — exiting", err); + return; } }; @@ -68,10 +69,11 @@ impl DeviceEnumerator { && !flags.contains(PortFlags::PR); if !disabled_state { - panic!( - "Port {} isn't in the disabled state! Current flags: {:?}", + warn!( + "Port {} isn't in the disabled state! Current flags: {:?} — skipping enumeration", port_id, flags ); + continue; } else { debug!("Port {} has entered the disabled state.", port_id); }