]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: drm: use `pin_init::zeroed()` for file operations initialization
authorAtharv Dubey <atharvd440@gmail.com>
Mon, 1 Dec 2025 15:27:58 +0000 (20:57 +0530)
committerAlice Ryhl <aliceryhl@google.com>
Thu, 18 Dec 2025 08:17:04 +0000 (08:17 +0000)
Replace the manual `unsafe { core::mem::zeroed() }` initialization of
`bindings::file_operations` with `pin_init::zeroed()`. This removes the
explicit unsafe

Signed-off-by: Atharv Dubey <atharvd440@gmail.com>
Link: https://patch.msgid.link/20251201152759.16429-1-atharvd440@gmail.com
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
rust/kernel/drm/gem/mod.rs

index 76e6c40d525e8aa5c30fa1881641973b061af5fa..bdaac839dacc99ebe03d37604f0fb4787ee27126 100644 (file)
@@ -293,9 +293,7 @@ impl<T: DriverObject> AllocImpl for Object<T> {
 }
 
 pub(super) const fn create_fops() -> bindings::file_operations {
-    // SAFETY: As by the type invariant, it is safe to initialize `bindings::file_operations`
-    // zeroed.
-    let mut fops: bindings::file_operations = unsafe { core::mem::zeroed() };
+    let mut fops: bindings::file_operations = pin_init::zeroed();
 
     fops.owner = core::ptr::null_mut();
     fops.open = Some(bindings::drm_open);