Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 083dd716 authored by Jiacheng Zheng's avatar Jiacheng Zheng
Browse files

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: default avatarJiacheng Zheng <jiaczhen@codeaurora.org>
parent 4687d601
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;
}