Skip to content

Commit

Permalink
kmemleak: record accurate early log buffer count and report when exce…
Browse files Browse the repository at this point in the history
…eded

In log_early function, crt_early_log should also count once when
'crt_early_log >= ARRAY_SIZE(early_log)'.  Otherwise the reported count
from kmemleak_init is one less than 'actual number'.

Then, in kmemleak_init, if early_log buffer size equal actual number,
kmemleak will init sucessful, so change warning condition to
'crt_early_log > ARRAY_SIZE(early_log)'.

Signed-off-by: Wang Kai <[email protected]>
Acked-by: Catalin Marinas <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Wang Kai authored and torvalds committed Sep 8, 2015
1 parent e397589 commit 21cd3a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm/kmemleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ static void __init log_early(int op_type, const void *ptr, size_t size,
}

if (crt_early_log >= ARRAY_SIZE(early_log)) {
crt_early_log++;
kmemleak_disable();
return;
}
Expand Down Expand Up @@ -1882,7 +1883,7 @@ void __init kmemleak_init(void)
object_cache = KMEM_CACHE(kmemleak_object, SLAB_NOLEAKTRACE);
scan_area_cache = KMEM_CACHE(kmemleak_scan_area, SLAB_NOLEAKTRACE);

if (crt_early_log >= ARRAY_SIZE(early_log))
if (crt_early_log > ARRAY_SIZE(early_log))
pr_warning("Early log buffer exceeded (%d), please increase "
"DEBUG_KMEMLEAK_EARLY_LOG_SIZE\n", crt_early_log);

Expand Down

0 comments on commit 21cd3a6

Please sign in to comment.