Skip to content

Commit 32c00b9

Browse files
committed
WIP: rust: kernel: sync: lockdep.rs Box/Vec fixes
Signed-off-by: Janne Grunau <j@jannau.net
1 parent f149fe4 commit 32c00b9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

rust/kernel/sync/lockdep.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
c_str, fmt,
1111
init::InPlaceInit,
1212
new_mutex,
13-
prelude::{Box, Result, Vec},
13+
prelude::{KBox, KVec, Result},
1414
str::{CStr, CString},
1515
sync::Mutex,
1616
types::Opaque,
@@ -109,11 +109,11 @@ const LOCK_CLASS_BUCKETS: usize = 1024;
109109
fn caller_lock_class_inner() -> Result<&'static DynLockClassKey> {
110110
// This is just a hack to make the below static array initialization work.
111111
#[allow(clippy::declare_interior_mutable_const)]
112-
const ATOMIC_PTR: AtomicPtr<Mutex<Vec<&'static DynLockClassKey>>> =
112+
const ATOMIC_PTR: AtomicPtr<Mutex<KVec<&'static DynLockClassKey>>> =
113113
AtomicPtr::new(core::ptr::null_mut());
114114

115115
#[allow(clippy::complexity)]
116-
static LOCK_CLASSES: [AtomicPtr<Mutex<Vec<&'static DynLockClassKey>>>; LOCK_CLASS_BUCKETS] =
116+
static LOCK_CLASSES: [AtomicPtr<Mutex<KVec<&'static DynLockClassKey>>>; LOCK_CLASS_BUCKETS] =
117117
[ATOMIC_PTR; LOCK_CLASS_BUCKETS];
118118

119119
let loc = core::panic::Location::caller();
@@ -124,10 +124,10 @@ fn caller_lock_class_inner() -> Result<&'static DynLockClassKey> {
124124

125125
let mut ptr = slot.load(Ordering::Relaxed);
126126
if ptr.is_null() {
127-
let new_element = Box::pin_init(new_mutex!(Vec::new()), GFP_KERNEL)?;
127+
let new_element = KBox::pin_init(new_mutex!(KVec::new()), GFP_KERNEL)?;
128128

129129
// SAFETY: We never move out of this Box
130-
let raw = Box::into_raw(unsafe { Pin::into_inner_unchecked(new_element) });
130+
let raw = KBox::into_raw(unsafe { Pin::into_inner_unchecked(new_element) });
131131

132132
if slot
133133
.compare_exchange(
@@ -139,7 +139,7 @@ fn caller_lock_class_inner() -> Result<&'static DynLockClassKey> {
139139
.is_err()
140140
{
141141
// SAFETY: We just got this pointer from `into_raw()`
142-
unsafe { drop(Box::from_raw(raw)) };
142+
unsafe { drop(KBox::from_raw(raw)) };
143143
}
144144

145145
ptr = slot.load(Ordering::Relaxed);
@@ -157,7 +157,7 @@ fn caller_lock_class_inner() -> Result<&'static DynLockClassKey> {
157157
}
158158

159159
// We immediately leak the class, so it becomes 'static
160-
let new_class = Box::leak(Box::new(
160+
let new_class = KBox::leak(KBox::new(
161161
DynLockClassKey {
162162
key: Opaque::zeroed(),
163163
loc: loc_key,

0 commit comments

Comments
 (0)