mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: m.szyprowski@samsung.com, robin.murphy@arm.com
Cc: ailiop@suse.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH v2 1/2] dma-debug: Skip debugfs registration when uninitialized
Date: Thu, 19 Nov 2026 15:13:24 +0200	[thread overview]
Message-ID: <91e9fa52ed35754f62c7fdecfad266a7213d4602.1795093513.git.thnkslprpt@gmail.com> (raw)
In-Reply-To: <cover.1795093513.git.thnkslprpt@gmail.com>

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@gmail.com>
---
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


  reply	other threads:[~2026-11-19 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:13 [PATCH v2 0/2] dma-debug: Avoid uninitialized mapping dumps Avi Weiss
2026-11-19 13:13 ` Avi Weiss [this message]
2026-11-19 13:13 ` [PATCH v2 2/2] dma-debug: Remove obsolete mapping dump helper Avi Weiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91e9fa52ed35754f62c7fdecfad266a7213d4602.1795093513.git.thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=ailiop@suse.com \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®