lkml.org 
[lkml]   [2020]   [Jun]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/cma: fix NULL pointer dereference when cma could not be activated
Date
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>
---
mm/cma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/cma.c b/mm/cma.c
index 0463ad2ce06b..488496fa2972 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,
--
2.17.1


\
 
 \ /
  Last update: 2020-06-15 03:08    [W:0.031 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site