]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: sync: fix safety comment for `static_lock_class`
authorBenno Lossin <lossin@kernel.org>
Tue, 20 May 2025 23:17:13 +0000 (01:17 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 22 Jul 2025 11:52:14 +0000 (13:52 +0200)
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>
rust/kernel/sync.rs

index 63c99e015ad6f6ef3ba145f7fa82443494e7af75..096cb78c8ec3e523ae3690e9e1124b178ae6dda7 100644 (file)
@@ -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)
     }};