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:
@@ -28,7 +28,8 @@ impl<const N: usize> DeviceEnumerator<N> {
|
||||
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<const N: usize> DeviceEnumerator<N> {
|
||||
&& !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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user