mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: replace as <pointer> casts with safer alternatives
`as` casts can change mutability, which quickly leads to undefined behavior. Signed-off-by: Julian Schindel <mail@arctic-alpaca.de>
This commit is contained in:
committed by
Rob Bradford
parent
8b101fb890
commit
ae7113e1d4
@@ -1081,7 +1081,7 @@ impl VirtioDevice for Iommu {
|
||||
fn write_config(&mut self, offset: u64, data: &[u8]) {
|
||||
// The "bypass" field is the only mutable field
|
||||
let bypass_offset =
|
||||
(&self.config.bypass as *const _ as u64) - (&self.config as *const _ as u64);
|
||||
(&raw const self.config.bypass as u64) - (&raw const self.config as u64);
|
||||
if offset != bypass_offset || data.len() != std::mem::size_of_val(&self.config.bypass) {
|
||||
error!(
|
||||
"Attempt to write to read-only field: offset {:x} length {}",
|
||||
|
||||
Reference in New Issue
Block a user