From: Baptiste Lepers Date: Tue, 12 Aug 2025 14:42:11 +0000 (+0200) Subject: rust: cpumask: Mark CpumaskVar as transparent X-Git-Tag: v6.18-rc1~49^2^2~2^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23fca458f6ab18927e50c2134fb7b60297f18b4e;p=thirdparty%2Fkernel%2Flinux.git rust: cpumask: Mark CpumaskVar as transparent Unsafe code in CpumaskVar's methods assumes that the type has the same layout as `bindings::cpumask_var_t`. This is not guaranteed by the default struct representation in Rust, but requires specifying the `transparent` representation. Fixes: 8961b8cb3099a ("rust: cpumask: Add initial abstractions") Signed-off-by: Baptiste Lepers Reviewed-by: Alice Ryhl Signed-off-by: Viresh Kumar --- diff --git a/rust/kernel/cpumask.rs b/rust/kernel/cpumask.rs index e311ab9038dfd..c1d17826ae7bb 100644 --- a/rust/kernel/cpumask.rs +++ b/rust/kernel/cpumask.rs @@ -212,6 +212,7 @@ impl Cpumask { /// } /// assert_eq!(mask2.weight(), count); /// ``` +#[repr(transparent)] pub struct CpumaskVar { #[cfg(CONFIG_CPUMASK_OFFSTACK)] ptr: NonNull,