From 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 2 Sep 2026 15:31:14 -0700 Subject: treewide: refresh kmalloc_obj() conversions This is another run of the Coccinelle script for converting kmalloc() family of allocations to kmalloc_obj() via the existing rules in scripts/coccinelle/api/kmalloc_objs.cocci This catches both the set of kmalloc() uses added since the first kmalloc_obj() conversions in v7.0 and adds a large group missed in the first pass due to Coccinelle not interacting well with the cleanup.h scoped_...() family of macros[1]. I worked around this with spatch's "--macro-file" argument to a file with all the scoped_...() macros mapped to Coccinelle's YACFE_ITERATOR[2] as that was the closest viable control flow indicator I could find. Build tested allmodconfig on x86, arm64, arm, loongarch, mips, powerpc, riscv, and s390 with no new warnings. Link: https://lore.kernel.org/lkml/202609021314.8A9C0B8@keescook/ [1] Link: https://github.com/coccinelle/coccinelle/blob/master/standard.h [2] Signed-off-by: Kees Cook --- drivers/of/Kconfig | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 drivers/of/Kconfig (limited to 'drivers/of/Kconfig') diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig new file mode 100644 index 000000000..50697cc3b --- /dev/null +++ b/drivers/of/Kconfig @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: GPL-2.0 +config DTC + bool + +config GENERIC_BUILTIN_DTB + bool + +config BUILTIN_DTB_ALL + bool + +menuconfig OF + bool "Device Tree and Open Firmware support" + help + This option enables the device tree infrastructure. + It is automatically selected by platforms that need it or can + be enabled manually for unittests, overlays or + compile-coverage. + +if OF + +config OF_UNITTEST + bool "Device Tree runtime unit tests" + depends on OF_EARLY_FLATTREE + select IRQ_DOMAIN + select OF_RESOLVE + help + This option builds in test cases for the device tree infrastructure + that are executed once at boot time, and the results dumped to the + console. + + This option should only be enabled for a development kernel. The tests + will taint the kernel with TAINT_TEST. The tests will cause ERROR and + WARNING messages to print on the console. The tests will cause stack + traces to print on the console. It is possible that the tests will + leave the devicetree in a corrupted state. + + The unittest output will be verbose. Copy the output to a file + via capturing the console output or via the dmesg command. Process + this file with scripts/dtc/of_unittest_expect to reduce the + verbosity, test whether expected output is present, and to + summarize the results. + + If unsure, say N here. This option is not safe to enable. + +config OF_KUNIT_TEST + tristate "Devicetree KUnit Test" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This option builds KUnit unit tests for device tree infrastructure. + + If unsure, say N here, but this option is safe to enable. + +config OF_ALL_DTBS + bool "Build all Device Tree Blobs" + depends on COMPILE_TEST + select DTC + help + This option builds all possible Device Tree Blobs (DTBs) for the + current architecture. + + If unsure, say N here, but this option is safe to enable. + +config OF_FLATTREE + bool + select DTC + select LIBFDT + select CRC32 + +config OF_EARLY_FLATTREE + def_bool OF && !(SPARC || ALPHA || HEXAGON || M68K || PARISC || S390) + select DMA_DECLARE_COHERENT if HAS_DMA && HAS_IOMEM + select OF_FLATTREE + +config OF_PROMTREE + bool + +config OF_KOBJ + def_bool SYSFS + +# Hardly any platforms need this. It is safe to select, but only do so if you +# need it. +config OF_DYNAMIC + bool "Support for dynamic device trees" if OF_UNITTEST + select OF_KOBJ + help + On some platforms, the device tree can be manipulated at runtime. + While this option is selected automatically on such platforms, you + can enable it manually to improve device tree unit test coverage. + +config OF_ADDRESS + def_bool y + depends on !SPARC && (HAS_IOMEM || UML) + +config OF_IRQ + def_bool y + depends on !SPARC && IRQ_DOMAIN + +config OF_RESERVED_MEM + def_bool OF_EARLY_FLATTREE + +config OF_RESOLVE + bool + +config OF_OVERLAY + bool "Device Tree overlays" + select OF_DYNAMIC + select OF_FLATTREE + select OF_RESOLVE + help + Overlays are a method to dynamically modify part of the kernel's + device tree with dynamically loaded data. + While this option is selected automatically when needed, you can + enable it manually to improve device tree unit test coverage. + +config OF_OVERLAY_KUNIT_TEST + tristate "Device Tree overlay KUnit tests" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + select DTC + help + This option builds KUnit unit tests for the device tree overlay code. + + If unsure, say N here, but this option is safe to enable. + +config OF_NUMA + bool + +endif # OF -- cgit v1.3.1