From: Ewan Chorynski Date: Sun, 28 Dec 2025 16:15:23 +0000 (+0100) Subject: rust: drm: Improve safety comment when using `Pin::into_inner_unchecked` X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4348796233e736147e2e79c58784d0a9fb48867d;p=thirdparty%2Fkernel%2Flinux.git rust: drm: Improve safety comment when using `Pin::into_inner_unchecked` The safety requirements for `Pin::into_inner_unchecked` state that the returned pointer must be treated as pinned until it is dropped. Such a guarantee is provided by the `ARef` type. This patch improves the safety comment to better reflect this. Signed-off-by: Ewan Chorynski Link: https://patch.msgid.link/20251228-drm-gem-safety-comment-v2-1-99bb861c3371@ik.me Signed-off-by: Danilo Krummrich --- diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index bdaac839dacc9..d49a9ba026356 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -210,7 +210,7 @@ impl Object { // SAFETY: The arguments are all valid per the type invariants. to_result(unsafe { bindings::drm_gem_object_init(dev.as_raw(), obj.obj.get(), size) })?; - // SAFETY: We never move out of `Self`. + // SAFETY: We will never move out of `Self` as `ARef` is always treated as pinned. let ptr = KBox::into_raw(unsafe { Pin::into_inner_unchecked(obj) }); // SAFETY: `ptr` comes from `KBox::into_raw` and hence can't be NULL.