[PATCH] ARM: mm: Free memblock from free_initrd_mem()

From: Seung-Woo Kim
Date: Thu Jan 07 2021 - 04:45:17 EST


Even after free_initrd_mem(), memblock for initrd remains. Free
memblock for initrd from free_initrd_mem().

Reported-by: Jaehoon Chung <jh80.chung@xxxxxxxxxxx>
Signed-off-by: Seung-Woo Kim <sw0312.kim@xxxxxxxxxxx>
---
arch/arm/mm/init.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 828a256..f7db023 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -530,6 +530,13 @@ void free_initmem(void)
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
+#ifdef CONFIG_ARCH_KEEP_MEMBLOCK
+ unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE);
+ unsigned long aligned_end = ALIGN(end, PAGE_SIZE);
+
+ memblock_free(__pa(aligned_start), aligned_end - aligned_start);
+#endif
+
if (start == initrd_start)
start = round_down(start, PAGE_SIZE);
if (end == initrd_end)
--
1.7.4.1