Skip to content

Commit 4e6b5b8

Browse files
BennoLossinojeda
authored andcommitted
rust: sync: fix safety comment for static_lock_class
The safety comment mentions lockdep -- which from a Rust perspective isn't important -- and doesn't mention the real reason for why it's sound to create `LockClassKey` as uninitialized memory. Signed-off-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250520231714.323931-1-lossin@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 2875321 commit 4e6b5b8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

rust/kernel/sync.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ impl PinnedDrop for LockClassKey {
9595
macro_rules! static_lock_class {
9696
() => {{
9797
static CLASS: $crate::sync::LockClassKey =
98-
// SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
99-
// lock_class_key
98+
// Lockdep expects uninitialized memory when it's handed a statically allocated `struct
99+
// lock_class_key`.
100+
//
101+
// SAFETY: `LockClassKey` transparently wraps `Opaque` which permits uninitialized
102+
// memory.
100103
unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
101104
$crate::prelude::Pin::static_ref(&CLASS)
102105
}};

0 commit comments

Comments
 (0)