summaryrefslogtreecommitdiffstats
path: root/mm/sparse.c
diff options
context:
space:
mode:
authorMike Kravetz <kravetz@us.ibm.com>2006-05-21 00:00:05 +0200
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-21 21:59:17 +0200
commit12783b002db1f02c29353c8f698a85514420b9f4 (patch)
treed0cec6913308fb34d539192dd0928cd0d7aae714 /mm/sparse.c
parent[PATCH] build fix: CONFIG_MEMORY_HOTPLUG=y on i386 (diff)
downloadlinux-12783b002db1f02c29353c8f698a85514420b9f4.tar.xz
linux-12783b002db1f02c29353c8f698a85514420b9f4.zip
[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: Mike Kravetz <kravetz@us.ibm.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/sparse.c')
-rw-r--r--mm/sparse.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/mm/sparse.c b/mm/sparse.c
index c5e89eb9ac8f..100040c0dfb6 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -87,11 +87,8 @@ int __section_nr(struct mem_section* ms)
unsigned long root_nr;
struct mem_section* root;
- for (root_nr = 0;
- root_nr < NR_MEM_SECTIONS;
- root_nr += SECTIONS_PER_ROOT) {
- root = __nr_to_section(root_nr);
-
+ for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) {
+ root = __nr_to_section(root_nr * SECTIONS_PER_ROOT);
if (!root)
continue;