File tree Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 3737 toolchain : ${{ matrix.rust }}
3838 target : ${{ matrix.target }}
3939
40+ - if : ${{ matrix.rust=='1.65.0' }}
41+ run : cargo update --precise 2.0.106 --package syn
42+
4043 - name : Install armv7 libraries
4144 if : ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
4245 run : |
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212- Added async ` DelayNs ` implementation for ` tokio ` .
1313- Added feature flag for ` serial ` .
1414
15+ ### Fixed
16+
17+ - Fix UB (and remove unsafe block) in handling of SpiOperation::TransferInPlace
18+
1519## [ v0.4.0] - 2024-01-10
1620
1721### Changed
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ sysfs_gpio = { version = "0.6.1", optional = true }
3131i2cdev = { version = " 0.6.0" , optional = true }
3232nb = " 1"
3333serialport = { version = " 4.2.0" , default-features = false , optional = true }
34- spidev = { version = " 0.6.0 " , optional = true }
34+ spidev = { version = " 0.6.1 " , optional = true }
3535nix = { version = " 0.27.1" , optional = true }
3636tokio = { version = " 1" , default-features = false , optional = true }
3737
Original file line number Diff line number Diff line change @@ -173,9 +173,8 @@ mod embedded_hal_impl {
173173 }
174174
175175 fn transfer_in_place ( & mut self , words : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
176- let tx = words. to_owned ( ) ;
177176 self . 0
178- . transfer ( & mut SpidevTransfer :: read_write ( & tx , words) )
177+ . transfer ( & mut SpidevTransfer :: read_write_in_place ( words) )
179178 . map_err ( |err| SPIError { err } )
180179 }
181180
@@ -214,11 +213,7 @@ mod embedded_hal_impl {
214213 }
215214 } ,
216215 SpiOperation :: TransferInPlace ( buf) => {
217- let tx = unsafe {
218- let p = buf. as_ptr ( ) ;
219- std:: slice:: from_raw_parts ( p, buf. len ( ) )
220- } ;
221- transfers. push ( SpidevTransfer :: read_write ( tx, buf) ) ;
216+ transfers. push ( SpidevTransfer :: read_write_in_place ( buf) ) ;
222217 }
223218 SpiOperation :: DelayNs ( ns) => {
224219 let us = {
You can’t perform that action at this time.
0 commit comments