From: Gavin Shan Date: Tue, 31 Jul 2012 23:46:04 +0000 (-0700) Subject: mm/sparse: more checks on mem_section number X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=db36a46113e101a8aa2d6ede41e78f2eaabed3f1;p=openwrt%2Fstaging%2Fblogic.git 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 Acked-by: David Rientjes Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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); }