]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
openrisc: Call setup_memory() earlier in the init sequence
authorOreoluwa Babatunde <quic_obabatun@quicinc.com>
Sat, 10 Feb 2024 00:29:30 +0000 (16:29 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Sep 2024 11:17:38 +0000 (13:17 +0200)
[ Upstream commit 7b432bf376c9c198a7ff48f1ed14a14c0ffbe1fe ]

The unflatten_and_copy_device_tree() function contains a call to
memblock_alloc(). This means that memblock is allocating memory before
any of the reserved memory regions are set aside in the setup_memory()
function which calls early_init_fdt_scan_reserved_mem(). Therefore,
there is a possibility for memblock to allocate from any of the
reserved memory regions.

Hence, move the call to setup_memory() to be earlier in the init
sequence so that the reserved memory regions are set aside before any
allocations are done using memblock.

Signed-off-by: Oreoluwa Babatunde <quic_obabatun@quicinc.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/openrisc/kernel/setup.c

index c6f9e7b9f7cb23f165e127b153a45595ca582baf..8c65810eeca24faf7ae687a43591ee38a1e47ab1 100644 (file)
@@ -284,6 +284,9 @@ void calibrate_delay(void)
 
 void __init setup_arch(char **cmdline_p)
 {
+       /* setup memblock allocator */
+       setup_memory();
+
        unflatten_and_copy_device_tree();
 
        setup_cpuinfo();
@@ -310,9 +313,6 @@ void __init setup_arch(char **cmdline_p)
        }
 #endif
 
-       /* setup memblock allocator */
-       setup_memory();
-
        /* paging_init() sets up the MMU and marks all pages as reserved */
        paging_init();