diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index b37e7cbea..ece070049 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -34,9 +34,7 @@ impl AcpiShutdownDevice { impl BusDevice for AcpiShutdownDevice { // Spec has all fields as zero fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) { - for i in data.iter_mut() { - *i = 0; - } + data.fill(0) } fn write(&mut self, _base: u64, _offset: u64, data: &[u8]) -> Option> { @@ -191,6 +189,10 @@ impl Default for AcpiPmTimerDevice { impl BusDevice for AcpiPmTimerDevice { fn read(&mut self, _base: u64, _offset: u64, data: &mut [u8]) { + if data.len() != std::mem::size_of::() { + warn!("Invalid sized read of PM timer: {}", data.len()); + return; + } let now = Instant::now(); let since = now.duration_since(self.start); let nanos = since.as_nanos();