mm/memblock.c: fix bug in early_dyn_memhotplug

memblock.memory.cnt will decrease if we remove all memory
blocks in a region. We will lose the next region in this
condition. The solution is we save memblock.memory.cnt
before we scan through a region and compare the new
counter with the old one after that, we decrease the idx
if we find counter changes. This way, we are always using
the correct idx before we enter next loop.

Change-Id: Id6bf83497f1048cf614e50e23484f2dea7ffcd07
Signed-off-by: Jiacheng Zheng <jiaczhen@codeaurora.org>
tirimbino
Jiacheng Zheng 5 years ago
parent 4687d601ea
commit 083dd7168b
  1. 6
      mm/memblock.c

@ -1833,12 +1833,14 @@ static bool __init memblock_in_no_hotplug_area(phys_addr_t addr)
static int __init early_dyn_memhotplug(char *p)
{
int idx = 0;
unsigned long idx = 0;
unsigned long old_cnt;
phys_addr_t addr, rgn_end;
struct memblock_region *rgn;
int blk = 0;
while (idx < memblock.memory.cnt) {
old_cnt = memblock.memory.cnt;
rgn = &memblock.memory.regions[idx++];
addr = ALIGN(rgn->base, MIN_MEMORY_BLOCK_SIZE);
rgn_end = rgn->base + rgn->size;
@ -1849,6 +1851,8 @@ static int __init early_dyn_memhotplug(char *p)
}
addr += MIN_MEMORY_BLOCK_SIZE;
}
if (old_cnt != memblock.memory.cnt)
idx--;
}
return 0;
}

Loading…
Cancel
Save