Skip to content

Commit f7c8c94

Browse files
authored
Merge pull request #125 from jannic-dev-forks/v0.4.x
Prepare release v0.4.1 with fix for #120
2 parents e50b26d + e3f5643 commit f7c8c94

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
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: |

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v0.4.1] - 2025-11-06
11+
12+
### Fixed
13+
14+
- Fix UB (and remove unsafe block) in handling of SpiOperation::TransferInPlace
15+
1016
## [v0.4.0] - 2024-01-10
1117

1218
### Changed
@@ -152,7 +158,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
152158

153159
Initial release
154160

155-
[Unreleased]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.4.0...HEAD
161+
[Unreleased]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.4.1...HEAD
162+
[v0.4.1]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.4.0...v0.4.1
156163
[v0.4.0]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.4.0-alpha.4...v0.4.0
157164
[v0.4.0-alpha.4]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.4.0-alpha.3...v0.4.0-alpha.4
158165
[v0.4.0-alpha.3]: https://github.com/rust-embedded/linux-embedded-hal/compare/v0.4.0-alpha.2...v0.4.0-alpha.3

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords = ["Linux", "hal"]
99
license = "MIT OR Apache-2.0"
1010
name = "linux-embedded-hal"
1111
repository = "https://github.com/rust-embedded/linux-embedded-hal"
12-
version = "0.4.0"
12+
version = "0.4.1"
1313
edition = "2018"
1414

1515
[features]
@@ -29,7 +29,7 @@ sysfs_gpio = { version = "0.6.1", optional = true }
2929
i2cdev = { version = "0.6.0", optional = true }
3030
nb = "1"
3131
serialport = { version = "4.2.0", default-features = false }
32-
spidev = { version = "0.6.0", optional = true }
32+
spidev = { version = "0.6.1", optional = true }
3333
nix = "0.27.1"
3434

3535
[dev-dependencies]

src/spi.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff 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 = {

0 commit comments

Comments
 (0)