]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fdt_resize(): fix actualsize calculations with unaligned blobs
authorPeter Korsgaard <jacmet@sunsite.dk>
Wed, 14 Jan 2009 12:52:24 +0000 (13:52 +0100)
committerGerald Van Baren <vanbaren@cideas.com>
Sat, 17 Jan 2009 18:03:29 +0000 (13:03 -0500)
The code in fdt_resize() to extend the fdt size to end on a page boundary
is wrong for fdt's not located at an address aligned on a page boundary.
What's even worse, the code would make actualsize shrink rather than grow
if (blob & 0xfff) was bigger than the amount of padding added by ALIGN(),
causing fdt_add_mem_rsv to fail.

Fix it by aligning end address (blob + size) to a page boundary instead.
For aligned fdt's this is equivalent to what we had before.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
common/fdt_support.c

index 5a83bca48177d738f6d493283214ac6ca099167e..a79bc085b205a042ec146e255481d1e7cb934fc2 100644 (file)
@@ -610,7 +610,7 @@ int fdt_resize(void *blob)
                fdt_size_dt_strings(blob) + sizeof(struct fdt_reserve_entry);
 
        /* Make it so the fdt ends on a page boundary */
-       actualsize = ALIGN(actualsize, 0x1000);
+       actualsize = ALIGN(actualsize + ((uint)blob & 0xfff), 0x1000);
        actualsize = actualsize - ((uint)blob & 0xfff);
 
        /* Change the fdt header to reflect the correct size */