Skip to content

Commit fcf3a5b

Browse files
ctmarinastorvalds
authored andcommitted
mm: kmemleak: disable early logging in case of error
If an error occurs during kmemleak_init() (e.g. kmem cache cannot be created), kmemleak is disabled but kmemleak_early_log remains enabled. Subsequently, when the .init.text section is freed, the log_early() function no longer exists. To avoid a page fault in such scenario, ensure that kmemleak_disable() also disables early logging. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Reported-by: Qian Cai <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5336e52 commit fcf3a5b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/kmemleak.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,7 @@ static void kmemleak_disable(void)
19661966

19671967
/* stop any memory operation tracing */
19681968
kmemleak_enabled = 0;
1969+
kmemleak_early_log = 0;
19691970

19701971
/* check whether it is too early for a kernel thread */
19711972
if (kmemleak_initialized)
@@ -2009,7 +2010,6 @@ void __init kmemleak_init(void)
20092010

20102011
#ifdef CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF
20112012
if (!kmemleak_skip_disable) {
2012-
kmemleak_early_log = 0;
20132013
kmemleak_disable();
20142014
return;
20152015
}

0 commit comments

Comments
 (0)