summaryrefslogtreecommitdiffstats
path: root/mm/sparse.c
diff options
context:
space:
mode:
authorGavin Shan <shangw@linux.vnet.ibm.com>2012-07-31 16:46:04 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-31 18:42:49 -0700
commitdb36a46113e101a8aa2d6ede41e78f2eaabed3f1 (patch)
treebb438589b620dbdca16bf5918468cd56c5b19f42 /mm/sparse.c
parent5b760e64a64c8940cdccd0ba6fce19a9bd010d20 (diff)
downloadlinux-db36a46113e101a8aa2d6ede41e78f2eaabed3f1.tar.gz
linux-db36a46113e101a8aa2d6ede41e78f2eaabed3f1.tar.bz2
linux-db36a46113e101a8aa2d6ede41e78f2eaabed3f1.zip
mm/sparse: more checks on mem_section number
__section_nr() was implemented to retrieve the corresponding memory section number according to its descriptor. It's possible that the specified memory section descriptor doesn't exist in the global array. So add more checking on that and report an error for a wrong case. Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com> Acked-by: David Rientjes <rientjes@google.com> Cc: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/sparse.c')
-rw-r--r--mm/sparse.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/sparse.c b/mm/sparse.c
index fa933f43b2c9..42ca0ea9af1b 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -130,6 +130,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);
}