USB: eliminate panics in device_enumerator hotplug path

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.
This commit is contained in:
Red Bear OS
2026-07-07 17:02:29 +03:00
parent 7efa83d6bd
commit 21cf3d900c
@@ -28,7 +28,8 @@ impl<const N: usize> DeviceEnumerator<N> {
let request = match self.request_queue.recv() { let request = match self.request_queue.recv() {
Ok(req) => req, Ok(req) => req,
Err(err) => { 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<const N: usize> DeviceEnumerator<N> {
&& !flags.contains(PortFlags::PR); && !flags.contains(PortFlags::PR);
if !disabled_state { if !disabled_state {
panic!( warn!(
"Port {} isn't in the disabled state! Current flags: {:?}", "Port {} isn't in the disabled state! Current flags: {:?} — skipping enumeration",
port_id, flags port_id, flags
); );
continue;
} else { } else {
debug!("Port {} has entered the disabled state.", port_id); debug!("Port {} has entered the disabled state.", port_id);
} }