Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1702741

[PATCH] mm/vmstat: fix divide error at __fragmentation_index

From Wen Yang <wen.yang99@zte.com.cn>
Newsgroups linux.kernel
Subject [PATCH] mm/vmstat: fix divide error at __fragmentation_index
Date 2017-08-03 09:50 +0200
Message-ID <uaj3n-5gj-39@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Jiang Biao <jiang.biao2@zte.com.cn>

When order is -1 or too big, *1UL << order* will be 0, which will
cause divide error like this,

    divide error: 0000 [#1] SMP
    Call Trace:
     [<ffffffff81168423>] compaction_suitable+0x63/0xc0
     [<ffffffff81168a75>] compact_zone+0x35/0x950
     [<ffffffff811745b5>] ? free_percpu+0xb5/0x140
     [<ffffffff81092b23>] ? schedule_on_each_cpu+0x133/0x160
     [<ffffffff8116949c>] compact_node+0x10c/0x120
     [<ffffffff8116953c>] sysctl_compaction_handler+0x5c/0x90
     [<ffffffff811fa517>] proc_sys_call_handler+0x97/0xd0
     [<ffffffff811fa564>] proc_sys_write+0x14/0x20
     [<ffffffff81187368>] vfs_write+0xb8/0x1a0
     [<ffffffff81187c61>] sys_write+0x51/0x90
     [<ffffffff8100b052>] system_call_fastpath+0x16/0x1b

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..2f9d012 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 (!requested)
+                return 0;
+
 	if (!info->free_blocks_total)
 		return 0;
 
-- 
2.7.4

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm/vmstat: fix divide error at __fragmentation_index Wen Yang <wen.yang99@zte.com.cn> - 2017-08-03 09:50 +0200
  Re: [PATCH] mm/vmstat: fix divide error at __fragmentation_index Vlastimil Babka <vbabka@suse.cz> - 2017-08-03 10:20 +0200

csiph-web