summaryrefslogtreecommitdiffstats
path: root/mm/kmemleak.c
diff options
context:
space:
mode:
authorPatrick Wang <patrick.wang.shcn@gmail.com>2022-06-11 05:55:51 +0200
committerakpm <akpm@linux-foundation.org>2022-06-17 04:48:31 +0200
commit84c326299191042a719655d3327538fc52aa8473 (patch)
tree0c3e218c24ad5da09c873dc2490f92459e48e812 /mm/kmemleak.c
parentmm: kmemleak: add rbtree and store physical address for objects allocated wit... (diff)
downloadlinux-84c326299191042a719655d3327538fc52aa8473.tar.xz
linux-84c326299191042a719655d3327538fc52aa8473.zip
mm: kmemleak: check physical address when scan
Check the physical address of objects for its boundary when scan instead of in kmemleak_*_phys(). Link: https://lkml.kernel.org/r/20220611035551.1823303-5-patrick.wang.shcn@gmail.com Fixes: 23c2d497de21 ("mm: kmemleak: take a full lowmem check in kmemleak_*_phys()") Signed-off-by: Patrick Wang <patrick.wang.shcn@gmail.com> Suggested-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Yee Lee <yee.lee@mediatek.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/kmemleak.c')
-rw-r--r--mm/kmemleak.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index ee94b028cb8a..466126625d76 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1184,7 +1184,7 @@ void __ref kmemleak_alloc_phys(phys_addr_t phys, size_t size, gfp_t gfp)
{
pr_debug("%s(0x%pa, %zu)\n", __func__, &phys, size);
- if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
+ if (kmemleak_enabled)
/*
* Create object with OBJECT_PHYS flag and
* assume min_count 0.
@@ -1204,7 +1204,7 @@ void __ref kmemleak_free_part_phys(phys_addr_t phys, size_t size)
{
pr_debug("%s(0x%pa)\n", __func__, &phys);
- if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
+ if (kmemleak_enabled)
delete_object_part((unsigned long)phys, size, true);
}
EXPORT_SYMBOL(kmemleak_free_part_phys);
@@ -1218,7 +1218,7 @@ void __ref kmemleak_ignore_phys(phys_addr_t phys)
{
pr_debug("%s(0x%pa)\n", __func__, &phys);
- if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
+ if (kmemleak_enabled)
make_black_object((unsigned long)phys, true);
}
EXPORT_SYMBOL(kmemleak_ignore_phys);
@@ -1493,6 +1493,17 @@ static void kmemleak_scan(void)
dump_object_info(object);
}
#endif
+
+ /* ignore objects outside lowmem (paint them black) */
+ if ((object->flags & OBJECT_PHYS) &&
+ !(object->flags & OBJECT_NO_SCAN)) {
+ unsigned long phys = object->pointer;
+
+ if (PHYS_PFN(phys) < min_low_pfn ||
+ PHYS_PFN(phys + object->size) >= max_low_pfn)
+ __paint_it(object, KMEMLEAK_BLACK);
+ }
+
/* reset the reference count (whiten the object) */
object->count = 0;
if (color_gray(object) && get_object(object))