lkml.org 
[lkml]   [2025]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] rust: drm: use `pin_init::zeroed()` for file operations initialization
Date
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>
---
rust/kernel/drm/gem/mod.rs | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 30c853988b94..c220cf1966fd 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -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);
--
2.43.0

\
 
 \ /
  Last update: 2025-11-29 14:49    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog