From: Wen Yang <wen.yang99@zte.com.cn> To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, kirill.shutemov@linux.intel.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, wen.yang99@zte.com.cn, jiang.biao2@zte.com.cn Subject: [PATCH] mm/vmstat: fix divide error at __fragmentation_index Date: Thu, 3 Aug 2017 17:12:00 +0800 [thread overview] Message-ID: <1501751520-2598-1-git-send-email-wen.yang99@zte.com.cn> (raw) When order is -1 or too big, *1UL << order* will be 0, which will cause 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. Sugguested-by: VlastimilBabka <vbabka@suse.cz> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn> --- mm/vmstat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index 76f7367..6f0f1ae 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; -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Wen Yang <wen.yang99@zte.com.cn> To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, kirill.shutemov@linux.intel.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, wen.yang99@zte.com.cn, jiang.biao2@zte.com.cn Subject: [PATCH] mm/vmstat: fix divide error at __fragmentation_index Date: Thu, 3 Aug 2017 17:12:00 +0800 [thread overview] Message-ID: <1501751520-2598-1-git-send-email-wen.yang99@zte.com.cn> (raw) When order is -1 or too big, *1UL << order* will be 0, which will cause 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. Sugguested-by: VlastimilBabka <vbabka@suse.cz> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn> --- mm/vmstat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index 76f7367..6f0f1ae 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; -- 2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2017-08-03 9:00 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-08-03 9:12 Wen Yang [this message] 2017-08-03 9:12 ` [PATCH] mm/vmstat: fix divide error at __fragmentation_index Wen Yang -- strict thread matches above, loose matches on Subject: below -- 2017-08-03 8:46 jiang.biao2 2017-08-03 7:59 Wen Yang 2017-08-03 7:59 ` Wen Yang 2017-08-03 8:09 ` Vlastimil Babka 2017-08-03 8:09 ` Vlastimil Babka
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1501751520-2598-1-git-send-email-wen.yang99@zte.com.cn \ --to=wen.yang99@zte.com.cn \ --cc=akpm@linux-foundation.org \ --cc=hannes@cmpxchg.org \ --cc=jiang.biao2@zte.com.cn \ --cc=kirill.shutemov@linux.intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhocko@suse.com \ --cc=vbabka@suse.cz \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.