Skip to content

Commit

Permalink
sh: fix memory corruption of unflattened device tree
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rich Felker committed Apr 12, 2018
1 parent 9b7e30a commit eb6b693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 0 additions & 6 deletions arch/sh/boards/of-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ static void __init sh_of_setup(char **cmdline_p)
{
struct device_node *root;

#ifdef CONFIG_USE_BUILTIN_DTB
unflatten_and_copy_device_tree();
#else
unflatten_device_tree();
#endif

board_time_init = sh_of_time_init;

sh_mv.mv_name = "Unknown SH model";
Expand Down
8 changes: 8 additions & 0 deletions arch/sh/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ void __init setup_arch(char **cmdline_p)
/* Let earlyprintk output early console messages */
early_platform_driver_probe("earlyprintk", 1, 1);

#ifdef CONFIG_OF_FLATTREE
#ifdef CONFIG_USE_BUILTIN_DTB
unflatten_and_copy_device_tree();
#else
unflatten_device_tree();
#endif
#endif

paging_init();

#ifdef CONFIG_DUMMY_CONSOLE
Expand Down

0 comments on commit eb6b693

Please sign in to comment.