Skip to content

Commit

Permalink
mm/sparse: more checks on mem_section number
Browse files Browse the repository at this point in the history
__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>
  • Loading branch information
shangw authored and torvalds committed Aug 1, 2012
1 parent 5b760e6 commit db36a46
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit db36a46

Please sign in to comment.