Skip to content

Commit 7739ad0

Browse files
authored
Merge pull request torvalds#612 from wedsonaf/revocable-mutex-drop
rust: fix drop in `RevocableMutex`
2 parents 8856b56 + ee3cea3 commit 7739ad0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rust/kernel/sync/revocable_mutex.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use core::{
1111
mem::ManuallyDrop,
1212
ops::{Deref, DerefMut},
1313
pin::Pin,
14-
ptr::drop_in_place,
1514
};
1615

1716
/// The state within a `RevocableMutex` that is protected by a mutex.
@@ -138,10 +137,11 @@ impl<T: ?Sized> RevocableMutex<T> {
138137
return;
139138
}
140139

141-
// SAFETY: We know `inner.data` is valid because `is_available` is set to true. We'll drop
142-
// it here and set it to false so it isn't dropped again.
143-
unsafe { drop_in_place(&mut inner.data) };
144140
inner.is_available = false;
141+
142+
// SAFETY: We know `inner.data` is valid because `is_available` was true. We'll drop it
143+
// here, and given that we set `is_available` to false above, it won't be dropped again.
144+
unsafe { ManuallyDrop::drop(&mut inner.data) };
145145
}
146146
}
147147

0 commit comments

Comments
 (0)