[PATCH v2 1/2] dma-debug: Skip debugfs registration when uninitialized
From: Avi Weiss
Date: Thu Nov 19 2026 - 08:13:43 EST
dma_debug_init() returns without initializing the hash buckets when DMA
API debugging is disabled at boot. dma_debug_fs_init() still registers
the debugfs files, allowing a read of dma-api/dump to traverse an
uninitialized list and dereference NULL.
Skip debugfs registration unless dma_debug_initialized is set. Keep
the files available if debugging disables itself after initialization,
so previously recorded mappings remain accessible.
Fixes: 173735c346c4 ("dma-debug: fix debugfs initialization order")
Signed-off-by: Avi Weiss <thnkslprpt@xxxxxxxxx>
---
v2:
- check dma_debug_initialized before registering the debugfs
files instead of guarding both dump functions
kernel/dma/debug.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 36c1f7cbb2ae..6e554dcfc9b9 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -839,7 +839,12 @@ static const struct file_operations filter_fops = {
static int __init dma_debug_fs_init(void)
{
- struct dentry *dentry = debugfs_create_dir("dma-api", NULL);
+ struct dentry *dentry;
+
+ if (!dma_debug_initialized)
+ return 0;
+
+ dentry = debugfs_create_dir("dma-api", NULL);
debugfs_create_bool("disabled", 0444, dentry, &global_disable);
debugfs_create_u32("error_count", 0444, dentry, &error_count);
--
2.43.0