mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 14:33:24 -04:00
rust: drm: pin ioctl Device reference to Normal context
Explicitly annotate the Device reference produced by from_raw() in the ioctl dispatch macro as Device<_, Normal>. Without this annotation, the context is inferred from the handler's first parameter type, which would allow a handler declaring &Device<T, Registered> to obtain a Registered reference without runtime proof via RegistrationGuard. Reviewed-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com> Link: https://patch.msgid.link/20260628145406.2107056-11-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
@@ -134,7 +134,8 @@ macro_rules! declare_drm_ioctls {
|
||||
// FIXME: Currently there is nothing enforcing that the types of the
|
||||
// dev/file match the current driver these ioctls are being declared
|
||||
// for, and it's not clear how to enforce this within the type system.
|
||||
let dev = $crate::drm::device::Device::from_raw(raw_dev);
|
||||
let dev: &$crate::drm::device::Device<_, $crate::drm::Normal> =
|
||||
$crate::drm::device::Device::from_raw(raw_dev);
|
||||
|
||||
// Enforce that the handler accepts higher-ranked
|
||||
// lifetimes, preventing it from requiring 'static
|
||||
|
||||
Reference in New Issue
Block a user