[PATCH] drivers: base: test: DRIVER_PE_KUNIT_TEST should not select OF

Geert Uytterhoeven posted 1 patch 1 month, 1 week ago
drivers/base/test/Kconfig               | 1 -
drivers/base/test/property-entry-test.c | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
[PATCH] drivers: base: test: DRIVER_PE_KUNIT_TEST should not select OF
Posted by Geert Uytterhoeven 1 month, 1 week ago
Enabling a (modular) test should not silently enable additional kernel
functionality, as that may increase the attack vector for a product.

Fix this by skipping the new test when OF support is disabled instead of
selecting OF support.

Note that when OF support is disabled, the compiler optimizes away the
then unused reference to of_fwnode_ops in of_node_init(), so linking
succeeds.

Fixes: 0e6f8ccd4618afdb ("device property: add test cases for fwnode_for_each_child_node()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/base/test/Kconfig               | 1 -
 drivers/base/test/property-entry-test.c | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/test/Kconfig b/drivers/base/test/Kconfig
index 542ce07530a1c5ea..1ecf0791241a1b2e 100644
--- a/drivers/base/test/Kconfig
+++ b/drivers/base/test/Kconfig
@@ -17,7 +17,6 @@ config DM_KUNIT_TEST
 config DRIVER_PE_KUNIT_TEST
 	tristate "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS
 	depends on KUNIT
-	select OF
 	default KUNIT_ALL_TESTS
 
 config DRIVER_SWNODE_KUNIT_TEST
diff --git a/drivers/base/test/property-entry-test.c b/drivers/base/test/property-entry-test.c
index 855e73b9b21f2810..89cdfc2f8498d8c8 100644
--- a/drivers/base/test/property-entry-test.c
+++ b/drivers/base/test/property-entry-test.c
@@ -523,6 +523,9 @@ static void pe_test_child_iteration(struct kunit *test)
 	struct fwnode_handle *child;
 	int error, i, num;
 
+	if (!IS_ENABLED(CONFIG_OF))
+		kunit_skip(test, "requires CONFIG_OF");
+
 	static const struct software_node node = { .name = "sw" };
 	static const struct software_node node1 = { .name = "sw-1", .parent = &node};
 	static const struct software_node node2 = { .name = "sw-2", .parent = &node};
-- 
2.43.0
Re: [PATCH] drivers: base: test: DRIVER_PE_KUNIT_TEST should not select OF
Posted by Danilo Krummrich 3 weeks, 5 days ago
On Thu, 20 Aug 2026 17:23:29 +0200, Geert Uytterhoeven wrote:
> [PATCH] drivers: base: test: DRIVER_PE_KUNIT_TEST should not select OF

Applied, thanks!

  Branch: driver-core-linus
  Tree:   git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git

[1/1] drivers: base: test: DRIVER_PE_KUNIT_TEST should not select OF
      commit: bb3a94a68283

The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).

The patch is queued up for Linus's tree and should land in the next -rc release.