Skip to content

Commit

Permalink
mm: kmemleak: disable early logging in case of error
Browse files Browse the repository at this point in the history
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/20190731152302.42073-1-catalin.marinas@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Qian Cai <cai@lca.pw>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
ctmarinas authored and torvalds committed Aug 13, 2019
1 parent 5336e52 commit fcf3a5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/kmemleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,7 @@ static void kmemleak_disable(void)

/* stop any memory operation tracing */
kmemleak_enabled = 0;
kmemleak_early_log = 0;

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

#ifdef CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF
if (!kmemleak_skip_disable) {
kmemleak_early_log = 0;
kmemleak_disable();
return;
}
Expand Down

0 comments on commit fcf3a5b

Please sign in to comment.