All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked`
@ 2025-12-26 17:22 ` Ewan Chorynski via B4 Relay
  0 siblings, 0 replies; 4+ messages in thread
From: Ewan Chorynski @ 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

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>
---
 rust/kernel/drm/gem/mod.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --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] 4+ messages in thread

* [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked`
@ 2025-12-26 17:22 ` Ewan Chorynski via B4 Relay
  0 siblings, 0 replies; 4+ 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>
---
 rust/kernel/drm/gem/mod.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --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] 4+ messages in thread

* Re: [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked`
@ 2025-12-27  1:32 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-12-27  1:32 UTC (permalink / raw)
  To: oe-kbuild

:::::: 
:::::: Manual check reason: "high confidence checkpatch report"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251226-drm-gem-safety-comment-v1-1-5ae56d8194b9@ik.me>
References: <20251226-drm-gem-safety-comment-v1-1-5ae56d8194b9@ik.me>
TO: Ewan Chorynski via B4 Relay <devnull+ewan.chorynski.ik.me@kernel.org>
TO: David Airlie <airlied@gmail.com>
TO: Simona Vetter <simona@ffwll.ch>
TO: Danilo Krummrich <dakr@kernel.org>
TO: Alice Ryhl <aliceryhl@google.com>
TO: Miguel Ojeda <ojeda@kernel.org>
TO: Boqun Feng <boqun.feng@gmail.com>
TO: Gary Guo <gary@garyguo.net>
TO: "Björn Roy Baron" <bjorn3_gh@protonmail.com>
TO: Benno Lossin <lossin@kernel.org>
TO: Andreas Hindborg <a.hindborg@kernel.org>
TO: Trevor Gross <tmgross@umich.edu>

Hi Ewan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 6c8e404891e1059564d1a15a71d3d76070304dde]

url:    https://github.com/intel-lab-lkp/linux/commits/Ewan-Chorynski-via-B4-Relay/rust-drm-Improve-safety-comment-when-using-Pin-into_inner_unchecked/20251227-012429
base:   6c8e404891e1059564d1a15a71d3d76070304dde
patch link:    https://lore.kernel.org/r/20251226-drm-gem-safety-comment-v1-1-5ae56d8194b9%40ik.me
patch subject: [PATCH] rust: drm: Improve safety comment when using `Pin::into_inner_unchecked`
:::::: branch date: 8 hours ago
:::::: commit date: 8 hours ago
reproduce: (https://download.01.org/0day-ci/archive/20251227/202512270244.ZfMmBvw4-lkp@intel.com/reproduce)

# many are suggestions rather than must-fix

WARNING:REPEATED_WORD: Possible repeated word: 'to'
#10: 
comment to to better reflect this.

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [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
  -1 siblings, 0 replies; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2025-12-28  9:34 UTC | newest]

Thread overview: 4+ 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
2025-12-26 17:22 ` Ewan Chorynski via B4 Relay
2025-12-28  9:34 ` Alice Ryhl
  -- strict thread matches above, loose matches on Subject: below --
2025-12-27  1:32 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.