diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-04-13 16:12:26 -0700 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-04-28 18:20:29 -0600 |
commit | 8bfe9b5c3a684fe39eb58a65e466c103d1c32c9a (patch) | |
tree | eb7709a314b7ec5ba3eef1dcd60018f41d512a45 /drivers/of | |
parent | cf32eb89cb4e674f88e4af5025839d85d02485c6 (diff) | |
download | linux-stable-8bfe9b5c3a684fe39eb58a65e466c103d1c32c9a.tar.gz linux-stable-8bfe9b5c3a684fe39eb58a65e466c103d1c32c9a.tar.bz2 linux-stable-8bfe9b5c3a684fe39eb58a65e466c103d1c32c9a.zip |
of/flattree: Make unflatten_device_tree() safe to call from any arch
This patch makes unflatten_device_tree() safe to call from any arch
setup code with the following changes:
- Make sure initial_boot_params actually points to a device tree blob
before unflattening
- Make sure the initial_boot_params->magic field is correct
- If CONFIG_OF_FLATTREE is not set, then make unflatten_device_tree()
an empty static inline function.
This patch also adds some additional debug output to the top of
unflatten_device_tree().
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/fdt.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index dee4fb56b094..b6987bba8556 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -556,6 +556,21 @@ void __init unflatten_device_tree(void) pr_debug(" -> unflatten_device_tree()\n"); + if (!initial_boot_params) { + pr_debug("No device tree pointer\n"); + return; + } + + pr_debug("Unflattening device tree:\n"); + pr_debug("magic: %08x\n", be32_to_cpu(initial_boot_params->magic)); + pr_debug("size: %08x\n", be32_to_cpu(initial_boot_params->totalsize)); + pr_debug("version: %08x\n", be32_to_cpu(initial_boot_params->version)); + + if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) { + pr_err("Invalid device tree blob header\n"); + return; + } + /* First pass, scan for size */ start = ((unsigned long)initial_boot_params) + be32_to_cpu(initial_boot_params->off_dt_struct); |