summaryrefslogtreecommitdiff
path: root/rust/kernel/module_param.rs
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-10-14 14:20:03 +0100
committerMark Brown <broonie@kernel.org>2026-10-14 14:20:03 +0100
commite4622b8294abcb690ce7c8587bc8a49d14d2ef01 (patch)
treecf31370df373f06a1268a5f8a86b09d6f22c1d28 /rust/kernel/module_param.rs
parentbaa5f780c1804c1d0e8c4e918970ef3221c2e7e6 (diff)
parent08abfa5a161e1b6e6244cb2090b0530bc0920798 (diff)
downloadlinux-next-e4622b8294abcb690ce7c8587bc8a49d14d2ef01.tar.gz
linux-next-e4622b8294abcb690ce7c8587bc8a49d14d2ef01.zip
Merge branch 'modules-next' of https://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git
# Conflicts: # drivers/gpu/drm/clients/drm_fbdev_helper.c
Diffstat (limited to 'rust/kernel/module_param.rs')
-rw-r--r--rust/kernel/module_param.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
index f9a14765a926..1a2fcbf4a5b3 100644
--- a/rust/kernel/module_param.rs
+++ b/rust/kernel/module_param.rs
@@ -74,8 +74,13 @@ where
crate::error::from_result(|| {
let new_value = T::try_from_param_arg(arg)?;
- // SAFETY: By function safety requirements, this access is safe.
- let container = unsafe { &*((*param).__bindgen_anon_1.arg.cast::<SetOnce<T>>()) };
+ // SAFETY: By function safety requirements, `param` is valid for read.
+ let arg = unsafe { (*param).__bindgen_anon_1.arg };
+ let param_access_ptr = arg.cast::<ModuleParamAccess<T>>();
+ // SAFETY: The `arg` field is initialized with a pointer to a `static ModuleAccessParam` by
+ // the rust module macro. Thus, the pointer is valid for use as a reference.
+ let param_access = unsafe { &*(param_access_ptr) };
+ let container = &param_access.value;
container
.populate(new_value)