Skip to content

Commit

Permalink
kfence: test: fail fast if disabled at boot
Browse files Browse the repository at this point in the history
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/20210825105533.1247922-1-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Tested-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Marco Elver authored and Linus Torvalds committed Sep 8, 2021
1 parent 4bbf04a commit c40c6e5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/kfence/kfence_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,9 @@ static int test_init(struct kunit *test)
unsigned long flags;
int i;

if (!__kfence_pool)
return -EINVAL;

spin_lock_irqsave(&observed.lock, flags);
for (i = 0; i < ARRAY_SIZE(observed.lines); i++)
observed.lines[i][0] = '\0';
Expand Down

0 comments on commit c40c6e5

Please sign in to comment.