From: Wen Yang Date: Wed, 6 Sep 2017 23:24:06 +0000 (-0700) Subject: mm/vmstat: fix divide error at __fragmentation_index X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=88d6ac40c1c6b2334046d3f89f1911a3c8febd4c;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git mm/vmstat: fix divide error at __fragmentation_index When order is -1 or too big, *1UL << order* will be 0, which will cause a divide error. Although it seems that all callers of __fragmentation_index() will only do so with a valid order, the patch can make it more robust. Should prevent reoccurrences of https://bugzilla.kernel.org/show_bug.cgi?id=196555 Link: http://lkml.kernel.org/r/1501751520-2598-1-git-send-email-wen.yang99@zte.com.cn Signed-off-by: Wen Yang Reviewed-by: Jiang Biao Suggested-by: Vlastimil Babka Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/vmstat.c b/mm/vmstat.c index ba9b202e8500..05de233a6fca 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -870,6 +870,9 @@ static int __fragmentation_index(unsigned int order, struct contig_page_info *in { unsigned long requested = 1UL << order; + if (WARN_ON_ONCE(order >= MAX_ORDER)) + return 0; + if (!info->free_blocks_total) return 0;