Skip to content

Commit ec3a354

Browse files
committed
kmemleak: Add callbacks to the bootmem allocator
This patch adds kmemleak_alloc/free callbacks to the bootmem allocator. This would allow scanning of such blocks and help avoiding a whole class of false positives and more kmemleak annotations. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Ingo Molnar <mingo@elte.hu> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
1 parent 53238a6 commit ec3a354

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎mm/bootmem.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/pfn.h>
1313
#include <linux/bootmem.h>
1414
#include <linux/module.h>
15+
#include <linux/kmemleak.h>
1516

1617
#include <asm/bug.h>
1718
#include <asm/io.h>
@@ -335,6 +336,8 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
335336
{
336337
unsigned long start, end;
337338

339+
kmemleak_free_part(__va(physaddr), size);
340+
338341
start = PFN_UP(physaddr);
339342
end = PFN_DOWN(physaddr + size);
340343

@@ -354,6 +357,8 @@ void __init free_bootmem(unsigned long addr, unsigned long size)
354357
{
355358
unsigned long start, end;
356359

360+
kmemleak_free_part(__va(addr), size);
361+
357362
start = PFN_UP(addr);
358363
end = PFN_DOWN(addr + size);
359364

@@ -516,6 +521,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
516521
region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
517522
start_off);
518523
memset(region, 0, size);
524+
kmemleak_alloc(region, size, 1, 0);
519525
return region;
520526
}
521527

0 commit comments

Comments
 (0)