[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250523145125.523275-11-lossin@kernel.org>
Date: Fri, 23 May 2025 16:51:06 +0200
From: Benno Lossin <lossin@...nel.org>
To: FUJITA Tomonori <fujita.tomonori@...il.com>,
Trevor Gross <tmgross@...ch.edu>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
Danilo Krummrich <dakr@...nel.org>
Cc: Lyude Paul <lyude@...hat.com>,
netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 10/13] rust: phy: replace `MaybeUninit::zeroed().assume_init` 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.
Signed-off-by: Benno Lossin <lossin@...nel.org>
---
rust/kernel/net/phy.rs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index a59469c785e3..de38f123e50a 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -563,9 +563,7 @@ pub const fn create_phy_driver<T: Driver>() -> DriverVTable {
} else {
None
},
- // SAFETY: The rest is zeroed out to initialize `struct phy_driver`,
- // sets `Option<&F>` to be `None`.
- ..unsafe { core::mem::MaybeUninit::<bindings::phy_driver>::zeroed().assume_init() }
+ ..pin_init::zeroed()
}))
}
--
2.49.0
Powered by blists - more mailing lists