mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: drm: gem: shmem: Drop unused unsafe for vm_ops assignment
@ 2026-11-25 12:24 Janne Grunau
  2026-11-25 22:12 ` Gary Guo
  0 siblings, 1 reply; 2+ messages in thread
From: Janne Grunau @ 2026-11-25 12:24 UTC (permalink / raw)
  To: David Airlie, Simona Vetter, Danilo Krummrich, Alice Ryhl,
	Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: dri-devel, rust-for-linux, linux-kernel, Janne Grunau

The assignment uses a raw const pointer referencing the static const
drm_gem_shmem_vm_ops from C side. This is safe since Rust 1.82.0 as
stated by the #[allow(unused_unsafe)]` attribute.
This was added in parallel with commit f32fb9c58a5b ("rust: bump Rust
minimum supported version to 1.85.0 (Debian Trixie)") for Linux v7.1.
Drop the unsafe, the SAFETY comment and the attribute as they are always
unused with Rust 1.85.0 and later.

Signed-off-by: Janne Grunau <j@jannau.net>
---
randomly spotted while looking at the source, no other
`#[allow(unused_unsafe)]` in rust/kernel can be dropped for the same
reason.
Tested with rust 1.85.1 and 1.100.0
---
 rust/kernel/drm/gem/shmem.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs
index 24cb5343e0db..fb8c70d0e4c8 100644
--- a/rust/kernel/drm/gem/shmem.rs
+++ b/rust/kernel/drm/gem/shmem.rs
@@ -138,9 +138,7 @@ impl<T: DriverObject> Object<T> {
         vmap: Some(bindings::drm_gem_shmem_object_vmap),
         vunmap: Some(bindings::drm_gem_shmem_object_vunmap),
         mmap: Some(bindings::drm_gem_shmem_object_mmap),
-        #[allow(unused_unsafe, reason = "Safe since Rust 1.82.0")]
-        // SAFETY: `drm_gem_shmem_vm_ops` is a valid, static const on the C side.
-        vm_ops: unsafe { &raw const bindings::drm_gem_shmem_vm_ops },
+        vm_ops: &raw const bindings::drm_gem_shmem_vm_ops,
         ..pin_init::zeroed()
     };
 

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261125-rust-drm-gem-shmem-unused-unsafe-559fa1565661

Best regards,
-- 
Janne Grunau <j@jannau.net>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 22:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 12:24 [PATCH] rust: drm: gem: shmem: Drop unused unsafe for vm_ops assignment Janne Grunau
2026-11-25 22:12 ` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®