Skip to contentSkip to conversation

rust: drm: use `pin_init::zeroed()` for file operations initialization

PATCH Superseded Atharv Dubey 2 participants 3 messages Nov 29, 2025 – Dec 1, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: drm: use `pin_init::zeroed()` for file operations initialization

Replace the manual unsafe { core::mem::zeroed() } initialization of bindings::file_operations with pin_init::zeroed(). This removes the explicit unsafe

---
 rust/kernel/drm/gem/mod.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
rust/kernel/drm/gem/mod.rs +2 -3
index 30c853988b94..c220cf1966fd 100644
@@ -298,9 +298,8 @@ 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);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 2 lines · Atharv Dubey

+

Spurious newline?

Cheers,
Miguel

#2 lore raw
Quoted 8 lines · Miguel Ojeda
Quoted 2 lines · Atharv Dubey

+

Spurious newline?

Quoted 1 line

Sorry for this, I will send a V2 of the patch.

Cheers,
Miguel