summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorAlvin Sun <alvin.sun@linux.dev>2026-08-11 14:39:47 +0800
committerMiguel Ojeda <ojeda@kernel.org>2026-08-12 09:36:26 +0200
commit3ef975893041b9f826475298c802b5c046d0ba16 (patch)
treea09e03fe2872bac2c6d2c330244c367e74929674 /rust/kernel
parent7d3e99e93382f1a49eab5afe78586a66907e4ff3 (diff)
downloadlinux-3ef975893041b9f826475298c802b5c046d0ba16.tar.gz
linux-3ef975893041b9f826475298c802b5c046d0ba16.zip
rust: drm: set fops.owner from driver module pointer
Change `create_fops()` to accept an owner module pointer instead of hardcoding `null_mut()`, ensuring the kernel correctly tracks the module owning the DRM device's file operations. Assisted-by: opencode:glm-5.2 Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Alvin Sun <alvin.sun@linux.dev> Link: https://patch.msgid.link/20260811-fix-fops-owner-v10-5-7e71776f9dbe@linux.dev Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/drm/device.rs3
-rw-r--r--rust/kernel/drm/gem/mod.rs4
2 files changed, 4 insertions, 3 deletions
diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs
index 48d8b26282d1..81f9f7e59817 100644
--- a/rust/kernel/drm/device.rs
+++ b/rust/kernel/drm/device.rs
@@ -203,7 +203,8 @@ impl<T: drm::Driver> UnregisteredDevice<T> {
fops: &Self::GEM_FOPS,
};
- const GEM_FOPS: bindings::file_operations = drm::gem::create_fops();
+ const GEM_FOPS: bindings::file_operations =
+ drm::gem::create_fops(crate::module::this_module::<T::OwnerModule>().as_ptr());
/// Create a new `UnregisteredDevice` for a `drm::Driver`.
///
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index c8b66d816871..a7ba1453d40b 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -387,10 +387,10 @@ impl<T: DriverObject, Ctx: DeviceContext> AllocImpl for Object<T, Ctx> {
};
}
-pub(super) const fn create_fops() -> bindings::file_operations {
+pub(super) const fn create_fops(owner: *mut bindings::module) -> bindings::file_operations {
let mut fops: bindings::file_operations = pin_init::zeroed();
- fops.owner = core::ptr::null_mut();
+ fops.owner = owner;
fops.open = Some(bindings::drm_open);
fops.release = Some(bindings::drm_release);
fops.unlocked_ioctl = Some(bindings::drm_ioctl);