When KFENCE is compiled in but disabled at boot (KFENCE_SAMPLE_INTERVAL=0) or __kfence_pool is not allocated, every kfence kunit case fails with -EINVAL. Use kunit_skip() so they are reported as skipped instead. To: Alexander Potapenko To: Marco Elver To: Dmitry Vyukov To: Andrew Morton Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org Signed-off-by: Jia He --- mm/kfence/kfence_test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index 5725a367246d..e376329dd621 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -822,8 +822,10 @@ static int test_init(struct kunit *test) unsigned long flags; int i; - if (!__kfence_pool) - return -EINVAL; + if (!__kfence_pool) { + kunit_skip(test, "kfence pool not allocated or kfence not enabled"); + return 0; + } spin_lock_irqsave(&observed.lock, flags); for (i = 0; i < ARRAY_SIZE(observed.lines); i++) -- 2.34.1