]>
Commit | Line | Data |
---|---|---|
37554d48 SL |
1 | From 98920dbbf1e25afa93779056ed770ad512d1b6ac Mon Sep 17 00:00:00 2001 |
2 | From: Yue Hu <huyue2@yulong.com> | |
3 | Date: Mon, 13 May 2019 17:18:14 -0700 | |
4 | Subject: mm/cma.c: fix crash on CMA allocation if bitmap allocation fails | |
5 | ||
6 | [ Upstream commit 1df3a339074e31db95c4790ea9236874b13ccd87 ] | |
7 | ||
8 | f022d8cb7ec7 ("mm: cma: Don't crash on allocation if CMA area can't be | |
9 | activated") fixes the crash issue when activation fails via setting | |
10 | cma->count as 0, same logic exists if bitmap allocation fails. | |
11 | ||
12 | Link: http://lkml.kernel.org/r/20190325081309.6004-1-zbestahu@gmail.com | |
13 | Signed-off-by: Yue Hu <huyue2@yulong.com> | |
14 | Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> | |
15 | Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> | |
16 | Cc: Laura Abbott <labbott@redhat.com> | |
17 | Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> | |
18 | Cc: Randy Dunlap <rdunlap@infradead.org> | |
19 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
20 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
21 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
22 | --- | |
23 | mm/cma.c | 4 +++- | |
24 | 1 file changed, 3 insertions(+), 1 deletion(-) | |
25 | ||
26 | diff --git a/mm/cma.c b/mm/cma.c | |
27 | index bfe9f5397165..6ce6e22f82d9 100644 | |
28 | --- a/mm/cma.c | |
29 | +++ b/mm/cma.c | |
30 | @@ -106,8 +106,10 @@ static int __init cma_activate_area(struct cma *cma) | |
31 | ||
32 | cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL); | |
33 | ||
34 | - if (!cma->bitmap) | |
35 | + if (!cma->bitmap) { | |
36 | + cma->count = 0; | |
37 | return -ENOMEM; | |
38 | + } | |
39 | ||
40 | WARN_ON_ONCE(!pfn_valid(pfn)); | |
41 | zone = page_zone(pfn_to_page(pfn)); | |
42 | -- | |
43 | 2.20.1 | |
44 |