summaryrefslogtreecommitdiff
path: root/rust/kernel/sync.rs
diff options
context:
space:
mode:
authorBenno Lossin <lossin@kernel.org>2025-05-21 01:17:13 +0200
committerMiguel Ojeda <ojeda@kernel.org>2025-07-22 13:52:14 +0200
commit4e6b5b8ab3e28148d04a63defadc29cfc771b102 (patch)
tree0f1084d716641233f44a28f13ced0dabba0635ce /rust/kernel/sync.rs
parent28753212e0f9c61afd859acf1d678f5de7faa4b8 (diff)
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>
Diffstat (limited to 'rust/kernel/sync.rs')
-rw-r--r--rust/kernel/sync.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index 63c99e015ad6f..096cb78c8ec3e 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -95,8 +95,11 @@ impl PinnedDrop for LockClassKey {
macro_rules! static_lock_class {
() => {{
static CLASS: $crate::sync::LockClassKey =
- // SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
- // lock_class_key
+ // Lockdep expects uninitialized memory when it's handed a statically allocated `struct
+ // lock_class_key`.
+ //
+ // SAFETY: `LockClassKey` transparently wraps `Opaque` which permits uninitialized
+ // memory.
unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
$crate::prelude::Pin::static_ref(&CLASS)
}};