__highest_present_section_nr is a more strict boundary than NR_MEM_SECTIONS. So check __highest_present_sectioin_nr directly is enough. Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> --- drivers/base/memory.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index fe4b24f05f6a..e79e3361f632 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -833,11 +833,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; -- 2.15.1