mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-02 04:41:10 -04:00
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 <ewan.chorynski@ik.me> Link: https://patch.msgid.link/20251228-drm-gem-safety-comment-v2-1-99bb861c3371@ik.me Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
7acc70476f
commit
4348796233
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user