* [PATCH v2] rust: drm: fix GEM object pointer safety docs
[not found] <20260707160200.2798072-1-1479826151@qq.com>
@ 2026-07-07 16:33 ` Yilin Chen
2026-07-13 15:35 ` Alice Ryhl
0 siblings, 1 reply; 2+ messages in thread
From: Yilin Chen @ 2026-07-07 16:33 UTC (permalink / raw)
To: David Airlie, Simona Vetter, dri-devel, rust-for-linux
Cc: Miguel Ojeda, Danilo Krummrich, linux-kernel, Yilin Chen
IntoGEMObject::from_raw() receives a pointer to struct drm_gem_object,
not a pointer to Self. The previous documentation used Self even though
the function argument is the embedded GEM object pointer.
However, the pointer must not be any arbitrary valid drm_gem_object. The
implementations recover Self with container_of(), so the GEM object must
be embedded in a valid Self instance. This patch documents that requirement
explicitly.
Assisted-by: Codex:GPT-5
Signed-off-by: Yilin Chen <1479826151@qq.com>
---
Changes in v2:
- Require the drm_gem_object to be embedded in a valid Self instance,
rather than merely being any valid drm_gem_object.
rust/kernel/drm/gem/mod.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index c8b66d816..524ab0e39 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -118,7 +118,8 @@ pub trait IntoGEMObject: Sized + super::private::Sealed + AlwaysRefCounted {
///
/// # Safety
///
- /// - `self_ptr` must be a valid pointer to `Self`.
+ /// - `self_ptr` must be a valid pointer to the `struct drm_gem_object` embedded in a
+ /// valid instance of `Self`.
/// - The caller promises that holding the immutable reference returned by this function does
/// not violate rust's data aliasing rules and remains valid throughout the lifetime of `'a`.
unsafe fn from_raw<'a>(self_ptr: *mut bindings::drm_gem_object) -> &'a Self;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] rust: drm: fix GEM object pointer safety docs
2026-07-07 16:33 ` [PATCH v2] rust: drm: fix GEM object pointer safety docs Yilin Chen
@ 2026-07-13 15:35 ` Alice Ryhl
0 siblings, 0 replies; 2+ messages in thread
From: Alice Ryhl @ 2026-07-13 15:35 UTC (permalink / raw)
To: Yilin Chen
Cc: David Airlie, Simona Vetter, dri-devel, rust-for-linux,
Miguel Ojeda, Danilo Krummrich, linux-kernel
On Tue, Jul 07, 2026 at 04:33:33PM +0000, Yilin Chen wrote:
> IntoGEMObject::from_raw() receives a pointer to struct drm_gem_object,
> not a pointer to Self. The previous documentation used Self even though
> the function argument is the embedded GEM object pointer.
>
> However, the pointer must not be any arbitrary valid drm_gem_object. The
> implementations recover Self with container_of(), so the GEM object must
> be embedded in a valid Self instance. This patch documents that requirement
> explicitly.
>
> Assisted-by: Codex:GPT-5
> Signed-off-by: Yilin Chen <1479826151@qq.com>
Merged into drm-rust-next. Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-13 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260707160200.2798072-1-1479826151@qq.com>
2026-07-07 16:33 ` [PATCH v2] rust: drm: fix GEM object pointer safety docs Yilin Chen
2026-07-13 15:35 ` Alice Ryhl
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.