[PATCH v5 13/15] arch/um: don't initialize kasan if it's disabled

Baoquan He
2026-02-25T08:17:06Z

Here, kasan is disabled if specified 'kasan=off' in kernel cmdline.

And also wrap up the kasan code into CONFIG_KASAN ifdeffery scope.

Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: linux-um@lists.infradead.org
---
arch/um/kernel/mem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 89c8c8b94a79..2bf858ab35b5 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -62,8 +62,11 @@ static unsigned long brk_end;

void __init arch_mm_preinit(void)
{
+#ifdef CONFIG_KASAN
/* Safe to call after jump_label_init(). Enables KASAN. */
- kasan_init_generic();
+ if (!kasan_arg_disabled)
+ kasan_init_generic();
+#endif

/* clear the zero-page */
memset(empty_zero_page, 0, PAGE_SIZE);
--
2.52.0