Skip to content

Commit fd764e7

Browse files
metaspaceojeda
authored andcommitted
rust: block: fix wrong usage of lockdep API
When allocating `struct gendisk`, `GenDiskBuilder` is using a dynamic lock class key without registering the key. This is an incorrect use of the API, which causes a `WARN` trace. Fix the issue by using a static lock class key, which is more appropriate for the situation anyway. Fixes: 3253aba ("rust: block: introduce `kernel::block::mq` module") Reported-by: Behme Dirk (XC-CP/ESB5) <[email protected]> Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/x/topic/x/near/457090036 Signed-off-by: Andreas Hindborg <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Tested-by: Dirk Behme <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Applied `rustfmt`, reworded slightly and made Zulip link a permalink. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent b8673d5 commit fd764e7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

rust/kernel/block/mq/gen_disk.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//! C header: [`include/linux/blk_mq.h`](srctree/include/linux/blk_mq.h)
77
88
use crate::block::mq::{raw_writer::RawWriter, Operations, TagSet};
9-
use crate::error;
109
use crate::{bindings, error::from_err_ptr, error::Result, sync::Arc};
10+
use crate::{error, static_lock_class};
1111
use core::fmt::{self, Write};
1212

1313
/// A builder for [`GenDisk`].
@@ -93,8 +93,6 @@ impl GenDiskBuilder {
9393
name: fmt::Arguments<'_>,
9494
tagset: Arc<TagSet<T>>,
9595
) -> Result<GenDisk<T>> {
96-
let lock_class_key = crate::sync::LockClassKey::new();
97-
9896
// SAFETY: `bindings::queue_limits` contain only fields that are valid when zeroed.
9997
let mut lim: bindings::queue_limits = unsafe { core::mem::zeroed() };
10098

@@ -110,7 +108,7 @@ impl GenDiskBuilder {
110108
tagset.raw_tag_set(),
111109
&mut lim,
112110
core::ptr::null_mut(),
113-
lock_class_key.as_ptr(),
111+
static_lock_class!().as_ptr(),
114112
)
115113
})?;
116114

0 commit comments

Comments
 (0)