From 4b77b6ea1ab55e299b3fcd1b35044030b3ee7d77 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Thu, 21 Jan 2021 15:22:52 +0900 Subject: [PATCH] of: Fix wrong kmemleak ignore in reserved_mem If size is 0, then kmemleak object found for ignore object is not properly working and ignore should work for create kmemleak object. Fix the wrong kmemleak ignore usages in of_reserved_mem. This removes below kmemleak warnings: kmemleak: Not scanning unknown object at 0xffffffc0f4807000 kmemleak: Not scanning unknown object at 0xffffffc0f4800000 kmemleak: Not scanning unknown object at 0xffffffc007400000 ... [] kmemleak_no_scan+0xd8/0xe8 [] kmemleak_init+0x260/0x504 .. kmemleak: Early log backtrace: log_early+0x1d8/0x268 kmemleak_no_scan+0xbc/0xe8 fdt_init_reserved_mem+0x8b4/0x928 early_init_fdt_scan_reserved_mem+0x100/0x13c arm64_memblock_init+0x310/0x388 ... Change-Id: Idac1f672b06373f6eb7485d63b60747f2cf9f5b5 Fixes: commit 47a87b6930cd ("kmemleak: shouldn't scan reserved memory") Signed-off-by: Seung-Woo Kim --- drivers/of/of_reserved_mem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 0d706be..c4a7b04 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -315,13 +315,15 @@ void __init fdt_init_reserved_mem(void) if (prop) rmem->phandle = of_read_number(prop, len/4); - if (rmem->size == 0) + if (rmem->size == 0) { err = __reserved_mem_alloc_size(node, rmem->name, &rmem->base, &rmem->size); #ifdef CONFIG_AMLOGIC_MODIFY - kmemleak_no_scan(phys_to_virt(rmem->base)); + if (!err && rmem->size) + kmemleak_no_scan(phys_to_virt(rmem->base)); #endif + } if (err == 0) __reserved_mem_init_node(rmem); -- 2.7.4