Skip to content

Commit

Permalink
mm/memblock.c: call kmemleak directly from memblock_(alloc|free)
Browse files Browse the repository at this point in the history
Kmemleak could ignore memory blocks allocated via memblock_alloc()
leading to false positives during scanning.  This patch adds the
corresponding callbacks and removes kmemleak_free_* calls in
mm/nobootmem.c to avoid duplication.

The kmemleak_alloc() in mm/nobootmem.c is kept since
__alloc_memory_core_early() does not use memblock_alloc() directly.

Signed-off-by: Catalin Marinas <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
ctmarinas authored and torvalds committed Jun 6, 2014
1 parent 1741196 commit aedf95e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 8 additions & 2 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
(unsigned long long)base + size - 1,
(void *)_RET_IP_);

kmemleak_free_part(__va(base), size);
return memblock_remove_range(&memblock.reserved, base, size);
}

Expand Down Expand Up @@ -1043,9 +1044,14 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
align = SMP_CACHE_BYTES;

found = memblock_find_in_range_node(size, align, start, end, nid);
if (found && !memblock_reserve(found, size))
if (found && !memblock_reserve(found, size)) {
/*
* The min_count is set to 0 so that memblock allocations are
* never reported as leaks.
*/
kmemleak_alloc(__va(found), size, 0, 0);
return found;

}
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions mm/nobootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ unsigned long __init free_all_bootmem(void)
void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
unsigned long size)
{
kmemleak_free_part(__va(physaddr), size);
memblock_free(physaddr, size);
}

Expand All @@ -212,7 +211,6 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
*/
void __init free_bootmem(unsigned long addr, unsigned long size)
{
kmemleak_free_part(__va(addr), size);
memblock_free(addr, size);
}

Expand Down

0 comments on commit aedf95e

Please sign in to comment.