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


Groups > linux.kernel > #1702804 > unrolled thread

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

Started byWen Yang <wen.yang99@zte.com.cn>
First post2017-08-03 11:10 +0200
Last post2017-08-03 11:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm/vmstat: fix divide error at __fragmentation_index Wen Yang <wen.yang99@zte.com.cn> - 2017-08-03 11:10 +0200

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

FromWen Yang <wen.yang99@zte.com.cn>
Date2017-08-03 11:10 +0200
Subject[PATCH] mm/vmstat: fix divide error at __fragmentation_index
Message-ID<uakiJ-6iI-1@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web