Skip to content

Commit c40c6e5

Browse files
melvertorvalds
authored andcommitted
kfence: test: fail fast if disabled at boot
Fail kfence_test fast if KFENCE was disabled at boot, instead of each test case trying several seconds to allocate from KFENCE and failing. KUnit will fail all test cases if kunit_suite::init returns an error. Even if KFENCE was disabled, we still want the test to fail, so that CI systems that parse KUnit output will alert on KFENCE being disabled (accidentally or otherwise). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Marco Elver <[email protected]> Reported-by: Kefeng Wang <[email protected]> Tested-by: Kefeng Wang <[email protected]> Acked-by: Alexander Potapenko <[email protected]> Cc: Dmitry Vyukov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4bbf04a commit c40c6e5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/kfence/kfence_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,9 @@ static int test_init(struct kunit *test)
789789
unsigned long flags;
790790
int i;
791791

792+
if (!__kfence_pool)
793+
return -EINVAL;
794+
792795
spin_lock_irqsave(&observed.lock, flags);
793796
for (i = 0; i < ARRAY_SIZE(observed.lines); i++)
794797
observed.lines[i][0] = '\0';

0 commit comments

Comments
 (0)