Thread (19 messages) 19 messages, 4 authors, 2012-07-01
STALE5138d REVIEWED: 1 (0M)

[PATCH v2 3/3] mm/sparse: more check on mem_section number

From: Gavin Shan <hidden>
Date: 2012-06-27 17:29:08
Subsystem: memory management, memory management - core, the rest · Maintainers: Andrew Morton, David Hildenbrand, Linus Torvalds

Function __section_nr() was implemented to retrieve the corresponding
memory section number according to its descriptor. It's possible that
the specified memory section descriptor isn't existing in the global
array. So here to add more check on that and report error for wrong
case.

Signed-off-by: Gavin Shan <redacted>
Reviewed-by: Dave Hansen <redacted>
---
 mm/sparse.c |    2 ++
 1 file changed, 2 insertions(+)
diff --git a/mm/sparse.c b/mm/sparse.c
index a803599..8b8250e 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -149,6 +149,8 @@ int __section_nr(struct mem_section* ms)
 		     break;
 	}
 
+	VM_BUG_ON(root_nr >= NR_SECTION_ROOTS);
+
 	return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
 }
 
-- 
1.7.9.5

--
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>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help