[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c30740af-d0fd-cac7-6304-d7f5ce25a9e6@redhat.com>
Date: Mon, 15 Jun 2020 10:34:57 +0200
From: David Hildenbrand <david@...hat.com>
To: Jianqun Xu <jay.xu@...k-chips.com>, akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/cma: fix NULL pointer dereference when cma could not
be activated
On 15.06.20 03:01, Jianqun Xu wrote:
> 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@...k-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,
>
If cma_activate_area() fails, cma_init_reserved_areas() fails. AFAIKS,
init/main.c will ignore any errors via do_one_initcall(). So this seems
to be possible.
Reviewed-by: David Hildenbrand <david@...hat.com>
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists