drivers: base: test: DRIVER_PE_KUNIT_TEST should not select OF

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: 0e6f8ccd46 ("device property: add test cases for fwnode_for_each_child_node()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://patch.msgid.link/8dfb4afaf70b59cd33af9296464395470405187e.1787239268.git.geert@linux-m68k.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
Geert Uytterhoeven 2026-08-20 17:23:29 +02:00 committed by Danilo Krummrich
parent cee9395acd
commit bb3a94a682
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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};