aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2017-07-31 01:27:50 -0400
committerRich Felker <dalias@libc.org>2018-04-12 19:47:51 -0400
commiteb6b6930a70faefe04479a71088cc10366782d9a (patch)
treea86769cb20fbc28fc58ef509058ad1a5bc81b97f
parent9b7e30ab975334448dc4c82941a48a3685a7642b (diff)
sh: fix memory corruption of unflattened device tree
unflatten_device_tree() makes use of memblock allocation, and therefore must be called before paging_init() migrates the memblock allocation data to the bootmem framework. Otherwise the record of the allocation for the expanded device tree will be lost, and will eventually be clobbered when allocated for another use. Signed-off-by: Rich Felker <dalias@libc.org>
-rw-r--r--arch/sh/boards/of-generic.c6
-rw-r--r--arch/sh/kernel/setup.c8
2 files changed, 8 insertions, 6 deletions
diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
index 4feb7c86f4ac..46b2481eec90 100644
--- a/arch/sh/boards/of-generic.c
+++ b/arch/sh/boards/of-generic.c
@@ -126,12 +126,6 @@ static void __init sh_of_setup(char **cmdline_p)
126{ 126{
127 struct device_node *root; 127 struct device_node *root;
128 128
129#ifdef CONFIG_USE_BUILTIN_DTB
130 unflatten_and_copy_device_tree();
131#else
132 unflatten_device_tree();
133#endif
134
135 board_time_init = sh_of_time_init; 129 board_time_init = sh_of_time_init;
136 130
137 sh_mv.mv_name = "Unknown SH model"; 131 sh_mv.mv_name = "Unknown SH model";
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index b95c411d0333..d34e998b809f 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -330,6 +330,14 @@ void __init setup_arch(char **cmdline_p)
330 /* Let earlyprintk output early console messages */ 330 /* Let earlyprintk output early console messages */
331 early_platform_driver_probe("earlyprintk", 1, 1); 331 early_platform_driver_probe("earlyprintk", 1, 1);
332 332
333#ifdef CONFIG_OF_FLATTREE
334#ifdef CONFIG_USE_BUILTIN_DTB
335 unflatten_and_copy_device_tree();
336#else
337 unflatten_device_tree();
338#endif
339#endif
340
333 paging_init(); 341 paging_init();
334 342
335#ifdef CONFIG_DUMMY_CONSOLE 343#ifdef CONFIG_DUMMY_CONSOLE