Skip to content

Commit 972fa3a

Browse files
zhangqiang4torvalds
authored andcommitted
mm: kmemleak: alloc gray object for reserved region with direct map
Reserved regions with direct mapping may contain references to other regions. CMA region with fixed location is reserved without creating kmemleak_object for it. So add them as gray kmemleak objects. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Calvin Zhang <[email protected]> Cc: Rob Herring <[email protected]> Cc: Frank Rowand <[email protected]> Cc: Catalin Marinas <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ad1a3e1 commit 972fa3a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/of/fdt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/serial_core.h>
2727
#include <linux/sysfs.h>
2828
#include <linux/random.h>
29+
#include <linux/kmemleak.h>
2930

3031
#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
3132
#include <asm/page.h>
@@ -522,9 +523,12 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
522523
size = dt_mem_next_cell(dt_root_size_cells, &prop);
523524

524525
if (size &&
525-
early_init_dt_reserve_memory_arch(base, size, nomap) == 0)
526+
early_init_dt_reserve_memory_arch(base, size, nomap) == 0) {
526527
pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n",
527528
uname, &base, (unsigned long)(size / SZ_1M));
529+
if (!nomap)
530+
kmemleak_alloc_phys(base, size, 0, 0);
531+
}
528532
else
529533
pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n",
530534
uname, &base, (unsigned long)(size / SZ_1M));

0 commit comments

Comments
 (0)