]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rust: drm: ensure kmalloc() compatible Layout
authorDanilo Krummrich <dakr@kernel.org>
Thu, 31 Jul 2025 15:48:07 +0000 (17:48 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Mon, 11 Aug 2025 21:21:45 +0000 (23:21 +0200)
commit22ab0641b939967f630d108e33a3582841ad6846
tree4699ba3c390ecdee2ad331935b9e4355d1fc56aa
parentfde578c86281f27b182680c7642836a0dbbd0be7
rust: drm: ensure kmalloc() compatible Layout

drm::Device is allocated through __drm_dev_alloc() (which uses
kmalloc()) and the driver private data, <T as drm::Driver>::Data, is
initialized in-place.

Due to the order of fields in drm::Device

  pub struct Device<T: drm::Driver> {
     dev: Opaque<bindings::drm_device>,
     data: T::Data,
  }

even with an arbitrary large alignment requirement of T::Data it can't
happen that the size of Device is smaller than its alignment requirement.

However, let's not rely on this subtle circumstance and create a proper
kmalloc() compatible Layout.

Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction")
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250731154919.4132-3-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/drm/device.rs