提交 12783b00 编写于 作者: M Mike Kravetz 提交者: Linus Torvalds

[PATCH] SPARSEMEM incorrectly calculates section number

A bad calculation/loop in __section_nr() could result in incorrect section
information being put into sysfs memory entries.  This primarily impacts
memory add operations as the sysfs information is used while onlining new
memory.

Fix suggested by Dave Hansen.

Note that the bug may not be obvious from the patch.  It actually occurs in
the function's return statement:

	return (root_nr * SECTIONS_PER_ROOT) + (ms - root);

In the existing code, root_nr has already been multiplied by
SECTIONS_PER_ROOT.
Signed-off-by: NMike Kravetz <kravetz@us.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 ad8f5797
...@@ -87,11 +87,8 @@ int __section_nr(struct mem_section* ms) ...@@ -87,11 +87,8 @@ int __section_nr(struct mem_section* ms)
unsigned long root_nr; unsigned long root_nr;
struct mem_section* root; struct mem_section* root;
for (root_nr = 0; for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) {
root_nr < NR_MEM_SECTIONS; root = __nr_to_section(root_nr * SECTIONS_PER_ROOT);
root_nr += SECTIONS_PER_ROOT) {
root = __nr_to_section(root_nr);
if (!root) if (!root)
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册