summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZijun Hu <quic_zijuhu@quicinc.com>2025-01-09 21:27:01 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:57:51 +0100
commit92ed1efb6ac009e3ce866e5f30a10796d2a7ec09 (patch)
treec01dc039861798d8277d0e87759d7914fe64c3ab
parent6cffdf48386c5592e70a110316360959e9cd2818 (diff)
of: reserved-memory: Do not make kmemleak ignore freed address
[ Upstream commit 29091a52562bca4d6e678dd8f0085dac119d6a21 ] early_init_dt_alloc_reserved_memory_arch() will free address @base when suffers memblock_mark_nomap() error, but it still makes kmemleak ignore the freed address @base via kmemleak_ignore_phys(). That is unnecessary, besides, also causes unnecessary warning messages: kmemleak_ignore_phys() -> make_black_object() -> paint_ptr() -> kmemleak_warn() // warning message here. Fix by avoiding kmemleak_ignore_phys() when suffer the error. Fixes: 658aafc8139c ("memblock: exclude MEMBLOCK_NOMAP regions from kmemleak") Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Link: https://lore.kernel.org/r/20250109-of_core_fix-v4-10-db8a72415b8c@quicinc.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/of/of_reserved_mem.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 46e1c3fbc769..fa5ecac0b6e9 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -51,7 +51,8 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
memblock_phys_free(base, size);
}
- kmemleak_ignore_phys(base);
+ if (!err)
+ kmemleak_ignore_phys(base);
return err;
}