mm: check __highest_present_section_nr directly in memory_dev_init()
authorWei Yang <[email protected]>
Tue, 10 Apr 2018 23:29:23 +0000 (16:29 -0700)
committerLinus Torvalds <[email protected]>
Wed, 11 Apr 2018 17:28:31 +0000 (10:28 -0700)
__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/[email protected]
Signed-off-by: Wei Yang <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/base/memory.c

index 79fcd2bae96b5246ccfa2fbff0dd4ebf3f277ad9..bffe8616bd55437e728404a90305b95f1a503dfc 100644 (file)
@@ -837,11 +837,8 @@ int __init memory_dev_init(void)
         * during boot and have been initialized
         */
        mutex_lock(&mem_sysfs_mutex);
-       for (i = 0; i < NR_MEM_SECTIONS; i += sections_per_block) {
-               /* Don't iterate over sections we know are !present: */
-               if (i > __highest_present_section_nr)
-                       break;
-
+       for (i = 0; i <= __highest_present_section_nr;
+               i += sections_per_block) {
                err = add_memory_block(i);
                if (!ret)
                        ret = err;