* [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked`
@ 2025-12-26 17:22 Ewan Chorynski via B4 Relay
2025-12-28 9:34 ` Alice Ryhl
0 siblings, 1 reply; 2+ messages in thread
From: Ewan Chorynski via B4 Relay @ 2025-12-26 17:22 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
Cc: dri-devel, rust-for-linux, linux-kernel, Ewan Chorynski
From: Ewan Chorynski <ewan.chorynski@ik.me>
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 improve the safety
comment to to better reflect this.
---
Signed-off-by: Ewan Chorynski <ewan.chorynski@ik.me>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index a7f682e95c01..ed11d9c0f427 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -210,7 +210,7 @@ pub fn new(dev: &drm::Device<T::Driver>, size: usize) -> Result<ARef<Self>> {
// 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<Self>` 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.
---
base-commit: 6c8e404891e1059564d1a15a71d3d76070304dde
change-id: 20251226-drm-gem-safety-comment-1152e457575f
Best regards,
--
Ewan Chorynski <ewan.chorynski@ik.me>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked`
2025-12-26 17:22 [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked` Ewan Chorynski via B4 Relay
@ 2025-12-28 9:34 ` Alice Ryhl
0 siblings, 0 replies; 2+ messages in thread
From: Alice Ryhl @ 2025-12-28 9:34 UTC (permalink / raw)
To: ewan.chorynski
Cc: David Airlie, Simona Vetter, Danilo Krummrich, Miguel Ojeda,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, dri-devel, rust-for-linux,
linux-kernel
Thanks for the patch!
On Fri, Dec 26, 2025 at 06:22:36PM +0100, Ewan Chorynski via B4 Relay wrote:
> From: Ewan Chorynski <ewan.chorynski@ik.me>
>
> 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 improve the safety
> comment to to better reflect this.
typo: This patch improves
typo: word "to" is duplicated twice
> ---
> Signed-off-by: Ewan Chorynski <ewan.chorynski@ik.me>
The Signed-off-by needs to go above the --- line. Otherwise it's not
included in the commit message.
Alice
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-28 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-26 17:22 [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked` Ewan Chorynski via B4 Relay
2025-12-28 9:34 ` Alice Ryhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox