From: Yue Hu Date: Tue, 14 May 2019 00:18:14 +0000 (-0700) Subject: mm/cma.c: fix crash on CMA allocation if bitmap allocation fails X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1df3a339074e31db95c4790ea9236874b13ccd87;p=linux.git mm/cma.c: fix crash on CMA allocation if bitmap allocation fails f022d8cb7ec7 ("mm: cma: Don't crash on allocation if CMA area can't be activated") fixes the crash issue when activation fails via setting cma->count as 0, same logic exists if bitmap allocation fails. Link: http://lkml.kernel.org/r/20190325081309.6004-1-zbestahu@gmail.com Signed-off-by: Yue Hu Reviewed-by: Anshuman Khandual Cc: Joonsoo Kim Cc: Laura Abbott Cc: Mike Rapoport Cc: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/cma.c b/mm/cma.c index d72a02fb77599..5e36d7418031c 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -106,8 +106,10 @@ static int __init cma_activate_area(struct cma *cma) cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!cma->bitmap) + if (!cma->bitmap) { + cma->count = 0; return -ENOMEM; + } WARN_ON_ONCE(!pfn_valid(pfn)); zone = page_zone(pfn_to_page(pfn));