mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
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>
This commit is contained in:
parent
1a5bae25e3
commit
835832ba01
2
mm/cma.c
2
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,
|
||||
|
Loading…
Reference in New Issue
Block a user