mirror of
https://github.com/torvalds/linux.git
synced 2026-10-22 23:01:49 +02:00
rust: lsm: replace core::mem::zeroed with pin_init::zeroed
All types in `bindings` implement `Zeroable` if they can, so use `pin_init::zeroed` instead of relying on `unsafe` code. If this ends up not compiling in the future, something in bindgen or on the C side changed and is most likely incorrect. Link: https://lore.kernel.org/r/20250814093046.2071971-8-lossin@kernel.org Link: https://github.com/Rust-for-Linux/linux/issues/1189 Signed-off-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Nils Lehnen <nils.lehnen@proton.me> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> [PM: subject tweak] Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
01f10e8c6a
commit
cd1f696de8
|
|
@ -62,8 +62,7 @@ impl SecurityCtx {
|
|||
/// Get the security context given its id.
|
||||
#[inline]
|
||||
pub fn from_secid(secid: u32) -> Result<Self> {
|
||||
// SAFETY: `struct lsm_context` can be initialized to all zeros.
|
||||
let mut ctx: bindings::lsm_context = unsafe { core::mem::zeroed() };
|
||||
let mut ctx: bindings::lsm_context = pin_init::zeroed();
|
||||
|
||||
// SAFETY: Just a C FFI call. The pointer is valid for writes.
|
||||
to_result(unsafe { bindings::security_secid_to_secctx(secid, &mut ctx) })?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user