ANDROID: GKI: of: reserved_mem: Fix kmemleak crash on no-map region

Unable to handle kernel paging request at virtual address
[<ffffff849b434d88>] scan_block+0x88/0x170
[<ffffff849b435070>] scan_gray_list+0x18c/0x1c0
[<ffffff849b4352ac>] kmemleak_scan+0x208/0x4b0
[<ffffff849b4359ec>] kmemleak_write+0x338/0x378
[<ffffff849b571068>] full_proxy_write+0x80/0xe4
[<ffffff849b43fe7c>] vfs_write+0xb4/0x1d0

early_init_dt_alloc_reserved_memory_arch() calls memblock_alloc_base(),
which will create a kmemleak entry. Ensure this entry is ignored if
the no-map property is set. This will prevent kmemleak from scanning
the object if there is no kernel mapping for it.

Bug: 153490586
Test: compile, verify MODVERSIONS CRC
Change-Id: I45f35600ae2aacf0f10f8bcbc956d019b666e4a7
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
(cherry picked from commit cf512e1d2c)
Signed-off-by: Will McVicker <willmcvicker@google.com>
This commit is contained in:
Patrick Daly 2017-09-29 18:04:45 -07:00 committed by Will McVicker
parent 36e1278b55
commit 7f3e23b3d8

View file

@ -20,6 +20,7 @@
#include <linux/of_reserved_mem.h>
#include <linux/sort.h>
#include <linux/slab.h>
#include <linux/kmemleak.h>
#define MAX_RESERVED_REGIONS 32
static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
@ -50,8 +51,10 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
}
*res_base = base;
if (nomap)
if (nomap) {
kmemleak_ignore_phys(base);
return memblock_remove(base, size);
}
return 0;
}
#else