summaryrefslogtreecommitdiffstats
path: root/mm/cma.c
diff options
context:
space:
mode:
authorJianqun Xu <jay.xu@rock-chips.com>2020-08-12 03:31:54 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2020-08-12 19:57:57 +0200
commit835832ba01bb444c7e45139e4b807527c119dafc (patch)
tree70fa999aa9337310c37ba78629cb5351f2019772 /mm/cma.c
parentmm/vmstat: add events for THP migration without split (diff)
downloadlinux-835832ba01bb444c7e45139e4b807527c119dafc.tar.xz
linux-835832ba01bb444c7e45139e4b807527c119dafc.zip
mm/cma.c: fix NULL pointer dereference when cma could not be activated
In some case the cma area could not be activated, but the cma_alloc be used under this case, then the kernel will crash caused by NULL pointer dereference. Add bitmap valid check in cma_alloc to avoid this issue. Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: David Hildenbrand <david@redhat.com> Link: http://lkml.kernel.org/r/20200615010123.15596-1-jay.xu@rock-chips.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/cma.c')
-rw-r--r--mm/cma.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/cma.c b/mm/cma.c
index 26ecff818881..3a18f8d8ea5e 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -425,7 +425,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
struct page *page = NULL;
int ret = -ENOMEM;
- if (!cma || !cma->count)
+ if (!cma || !cma->count || !cma->bitmap)
return NULL;
pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma,