Commit 2ce5966c authored by Miaohe Lin's avatar Miaohe Lin Committed by Zheng Zengkai
Browse files

memblock: use kfree() to release kmalloced memblock regions

stable inclusion
from stable-v5.10.103
commit 78706b051a8a314b55f13bcef3351e7d8e974a88
bugzilla: https://gitee.com/openeuler/kernel/issues/I56NE7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=78706b051a8a314b55f13bcef3351e7d8e974a88



--------------------------------

commit c94afc46 upstream.

memblock.{reserved,memory}.regions may be allocated using kmalloc() in
memblock_double_array(). Use kfree() to release these kmalloced regions
indicated by memblock_{reserved,memory}_in_slab.

Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Fixes: 3010f876 ("mm: discard memblock data later")
Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
Reviewed-by: default avatarWei Li <liwei391@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 500cba9d
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -366,6 +366,9 @@ void __init memblock_discard(void)
		addr = __pa(memblock.reserved.regions);
		size = PAGE_ALIGN(sizeof(struct memblock_region) *
				  memblock.reserved.max);
		if (memblock_reserved_in_slab)
			kfree(memblock.reserved.regions);
		else
			__memblock_free_late(addr, size);
	}

@@ -373,6 +376,9 @@ void __init memblock_discard(void)
		addr = __pa(memblock.memory.regions);
		size = PAGE_ALIGN(sizeof(struct memblock_region) *
				  memblock.memory.max);
		if (memblock_memory_in_slab)
			kfree(memblock.memory.regions);
		else
			__memblock_free_late(addr, size);
	}