diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs index 4c3af91924f6606082ea8eb3236946aa8e411e39..b98c8bc89041e12a51406776f2e7376ef90d08d3 100644 --- a/rust/kernel/sync/lock.rs +++ b/rust/kernel/sync/lock.rs @@ -252,6 +252,9 @@ impl<'a, T: ?Sized, B: Backend> Guard<'a, T, B> { state: B::GuardState, _context: B::Context<'a>, ) -> Self { + // SAFETY: The lock is guaranteed to be initialized by `Lock`'s type invariants + debug_assert!(unsafe { B::is_locked(lock.state.get()) }); + Self { lock, state,