Commit 620951e2 authored by Thierry Reding's avatar Thierry Reding Committed by Linus Torvalds

mm/cma: make kmemleak ignore CMA regions

kmemleak will add allocations as objects to a pool.  The memory allocated
for each object in this pool is periodically searched for pointers to
other allocated objects.  This only works for memory that is mapped into
the kernel's virtual address space, which happens not to be the case for
most CMA regions.

Furthermore, CMA regions are typically used to store data transferred to
or from a device and therefore don't contain pointers to other objects.

Without this, the kernel crashes on the first execution of the
scan_gray_list() because it tries to access highmem.  Perhaps a more
appropriate fix would be to reject any object that can't map to a kernel
virtual address?

[ add comment]
[ fix comment, per Catalin]
[ include linux/io.h for phys_to_virt()]
Signed-off-by: default avatarThierry Reding <>
Cc: Michal Nazarewicz <>
Cc: Marek Szyprowski <>
Cc: Joonsoo Kim <>
Cc: "Aneesh Kumar K.V" <>
Cc: Catalin Marinas <>
Signed-off-by: default avatarStephen Rothwell <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent dee2f8aa
......@@ -33,6 +33,7 @@
#include <linux/log2.h>
#include <linux/cma.h>
#include <linux/highmem.h>
#include <linux/io.h>
struct cma {
unsigned long base_pfn;
......@@ -324,6 +325,11 @@ int __init cma_declare_contiguous(phys_addr_t base,
* kmemleak scans/reads tracked objects for pointers to other
* objects but this address isn't mapped and accessible
base = addr;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment