mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 13:23:02 -04:00
rust: drm: fix GEM object pointer safety docs
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> Link: https://patch.msgid.link/tencent_4426892E62B77DEA2AE898E899A871940005@qq.com Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
@@ -117,7 +117,8 @@ pub trait IntoGEMObject: Sized + super::private::Sealed {
|
||||
///
|
||||
/// # 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;
|
||||
|
||||
Reference in New Issue
Block a user