]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/sparse: more checks on mem_section number
authorGavin Shan <shangw@linux.vnet.ibm.com>
Tue, 31 Jul 2012 23:46:04 +0000 (16:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Aug 2012 01:42:49 +0000 (18:42 -0700)
__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>
mm/sparse.c

index fa933f43b2c92b7308e307fb429fff4090aa9ab0..42ca0ea9af1bbba98336ad8016da0fdb0a532dc8 100644 (file)
@@ -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);
 }