Skip to content

Commit

Permalink
mm/cma.c: fix crash on CMA allocation if bitmap allocation fails
Browse files Browse the repository at this point in the history
f022d8c ("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 <huyue2@yulong.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Yue Hu authored and torvalds committed May 14, 2019
1 parent 113b7df commit 1df3a33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 1df3a33

Please sign in to comment.