Skip to content

Commit 9d0503e

Browse files
authored
Merge pull request #7 from YuhanLiin/remove-enable-cs
Remove enable_cs due to unsoundness
2 parents c42dbb0 + 5f377b8 commit 9d0503e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Removed
11+
- `enable_cs` removed due to soundness hole when interacting with `Clone` and
12+
`interrupt::free`.
13+
1014
## [v0.2.2] - 2020-04-23
1115

1216
### Changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords = ["msp430", "interrupt", "register", "peripheral"]
77
license = "MIT OR Apache-2.0"
88
name = "msp430"
99
repository = "https://github.com/rust-embedded/msp430"
10-
version = "0.2.2"
10+
version = "0.3.0"
1111

1212
[dependencies.bare-metal]
1313
features = ["const-fn"]

src/interrupt.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub fn disable() {
2323
///
2424
/// # Safety
2525
///
26-
/// - Do not call this function inside an `interrupt::free` critical section
26+
/// - In any function `f()` that calls `enable`, `CriticalSection` or `&CriticalSection` tokens cannot be used in `f()`'s body after the
27+
/// call to `enable`. If `f()` owns `CriticalSection` tokens, it is recommended to [`drop`](https://doc.rust-lang.org/nightly/core/mem/fn.drop.html)
28+
/// these tokens before calling `enable`.
2729
#[inline(always)]
2830
pub unsafe fn enable() {
2931
match () {
@@ -40,13 +42,6 @@ pub unsafe fn enable() {
4042
}
4143
}
4244

43-
/// Safely enables all interrupts by consuming a `CriticalSection`, which ensures that subsequent
44-
/// code cannot borrow from a `Mutex` without creating a new critical section.
45-
#[inline(always)]
46-
pub fn enable_cs(_cs: CriticalSection) {
47-
unsafe { enable() };
48-
}
49-
5045
/// Execute closure `f` in an interrupt-free context.
5146
///
5247
/// This as also known as a "critical section".

0 commit comments

Comments
 (0)