Commit bc8755ba authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds

mm: check __highest_present_section_nr directly in memory_dev_init()

__highest_present_section_nr is a more strict boundary than
NR_MEM_SECTIONS.  So checking __highest_present_section_nr directly is
enough.

Link: http://lkml.kernel.org/r/20180330032044.21647-1-richard.weiyang@gmail.comSigned-off-by: default avatarWei Yang <richard.weiyang@gmail.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 09a913a7
...@@ -837,11 +837,8 @@ int __init memory_dev_init(void) ...@@ -837,11 +837,8 @@ int __init memory_dev_init(void)
* during boot and have been initialized * during boot and have been initialized
*/ */
mutex_lock(&mem_sysfs_mutex); mutex_lock(&mem_sysfs_mutex);
for (i = 0; i < NR_MEM_SECTIONS; i += sections_per_block) { for (i = 0; i <= __highest_present_section_nr;
/* Don't iterate over sections we know are !present: */ i += sections_per_block) {
if (i > __highest_present_section_nr)
break;
err = add_memory_block(i); err = add_memory_block(i);
if (!ret) if (!ret)
ret = err; ret = err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment