summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2022-02-17 22:53:27 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-02 11:38:14 +0100
commita6fcced73d15ab57cd97813999edf6f19d3032f8 (patch)
tree243532462923b7f39842ad5bb9dbab1c5d373bd1 /mm
parent9429dfe53ce462d5f308e935625255d95a9aea55 (diff)
downloadlinux-stable-a6fcced73d15ab57cd97813999edf6f19d3032f8.tar.gz
linux-stable-a6fcced73d15ab57cd97813999edf6f19d3032f8.tar.bz2
linux-stable-a6fcced73d15ab57cd97813999edf6f19d3032f8.zip
memblock: use kfree() to release kmalloced memblock regions
commit c94afc46cae7ad41b2ad6a99368147879f4b0e56 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: Miaohe Lin <linmiaohe@huawei.com> Fixes: 3010f876500f ("mm: discard memblock data later") Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memblock.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 4f7c5c3c442c..4d471da3cc47 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -322,14 +322,20 @@ void __init memblock_discard(void)
addr = __pa(memblock.reserved.regions);
size = PAGE_ALIGN(sizeof(struct memblock_region) *
memblock.reserved.max);
- __memblock_free_late(addr, size);
+ if (memblock_reserved_in_slab)
+ kfree(memblock.reserved.regions);
+ else
+ __memblock_free_late(addr, size);
}
if (memblock.memory.regions != memblock_memory_init_regions) {
addr = __pa(memblock.memory.regions);
size = PAGE_ALIGN(sizeof(struct memblock_region) *
memblock.memory.max);
- __memblock_free_late(addr, size);
+ if (memblock_memory_in_slab)
+ kfree(memblock.memory.regions);
+ else
+ __memblock_free_late(addr, size);
}
}
#endif