Closed
Description
@repnop pointed out to me that https://github.com/stm32-rs/stm32f1xx-hal/blob/master/src/spi.rs#L261 and the write_volatile
call in serial.rs
is UB because constructing (or possibly writing) from a pointer created from a non-mut reference is UB.
A fix might be to just change it to
unsafe { ptr::write_volatile(&mut self.spi.dr as *const _ as *mut FrameSize, data) }
But spi.dr does not implement DerefMut
so this fix does not compile. I don't have time to look into it deeper than that today but we should be aware of this potential UB.
Edit: Removed a reference to an unrelated issue
Edit2: Removed the svd2rust part as well