[PATCH v2 0/2] dma-debug: Avoid uninitialized mapping dumps

From: Avi Weiss

Date: Thu Nov 19 2026 - 08:13:47 EST


Booting with dma_debug=off leaves the DMA-debug hash buckets
uninitialized, but the debugfs mapping dump is still registered.
Reading dma-api/dump then traverses an uninitialized list and
causes a NULL pointer dereference in dump_show().

Patch 1 skips debugfs registration when DMA debugging was not
initialized. Patch 2 removes the obsolete debug_dma_dump_mappings()
helper and its only caller in the legacy AMD GART IOMMU code.

Validation on x86-64 QEMU:
- baseline with dma_debug=off - NULL dereference in dump_show()
- patched with dma_debug=off - dma-api debugfs directory absent
- patched with DMA debugging enabled - mapping dump readable
- both objects compiled successfully with W=1

Changes since v1:
- guard debugfs registration instead of the dump paths, as
suggested by Anthony Iliopoulos
- remove the obsolete mapping dump helper and its AMD GART
caller (due to feedback from Robin Murphy and Marek Szyprowski)

v1 discussion:
https://lore-kernel.gnuweeb.org/linux-iommu/05c05ec4-b321-49d4-acf7-b9fa4223dba9%40samsung.com/T/


Avi Weiss (2):
dma-debug: Skip debugfs registration when uninitialized
dma-debug: Remove obsolete mapping dump helper

arch/x86/kernel/amd_gart_64.c | 1 -
include/linux/dma-map-ops.h | 4 ----
kernel/dma/debug.c | 40 ++++++-----------------------------
3 files changed, 6 insertions(+), 39 deletions(-)


base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0