From: Atharv Dubey Date: Mon, 1 Dec 2025 15:27:58 +0000 (+0530) Subject: rust: drm: use `pin_init::zeroed()` for file operations initialization X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97cf6bc0abd381fd84e5d8e978322a62a58fb00e;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Atharv Dubey Link: https://patch.msgid.link/20251201152759.16429-1-atharvd440@gmail.com Signed-off-by: Alice Ryhl --- diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index 76e6c40d525e8..bdaac839dacc9 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -293,9 +293,7 @@ impl AllocImpl for Object { } 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);