diff options
author | Li Zhong <zhong@linux.vnet.ibm.com> | 2014-08-06 19:07:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-06 21:01:21 -0400 |
commit | d0177639310d23c7739500df3c6ce6fdfe34acec (patch) | |
tree | c67d79bed5c81e24e6bf616786b6f21726b4f4d4 /mm | |
parent | 8fe780484d2674eec27e12bb29c07d3e98a7ad21 (diff) |
mm: fix potential infinite loop in dissolve_free_huge_pages()
It is possible for some platforms, such as powerpc to set HPAGE_SHIFT to
0 to indicate huge pages not supported.
When this is the case, hugetlbfs could be disabled during boot time:
hugetlbfs: disabling because there are no supported hugepage sizes
Then in dissolve_free_huge_pages(), order is kept maximum (64 for
64bits), and the for loop below won't end: for (pfn = start_pfn; pfn <
end_pfn; pfn += 1 << order)
As suggested by Naoya, below fix checks hugepages_supported() before
calling dissolve_free_huge_pages().
[rientjes@google.com: no legitimate reason to call dissolve_free_huge_pages() when !hugepages_supported()]
Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
Acked-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: <stable@vger.kernel.org> [3.12+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/hugetlb.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d9ad93b55585..eeceeeb09019 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -1088,6 +1088,9 @@ void dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn) | |||
1088 | unsigned long pfn; | 1088 | unsigned long pfn; |
1089 | struct hstate *h; | 1089 | struct hstate *h; |
1090 | 1090 | ||
1091 | if (!hugepages_supported()) | ||
1092 | return; | ||
1093 | |||
1091 | /* Set scan step to minimum hugepage size */ | 1094 | /* Set scan step to minimum hugepage size */ |
1092 | for_each_hstate(h) | 1095 | for_each_hstate(h) |
1093 | if (order > huge_page_order(h)) | 1096 | if (order > huge_page_order(h)) |