]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: fdt: Map address returned from fdt get addr to sysmem
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Thu, 2 Mar 2023 03:08:22 +0000 (04:08 +0100)
committerSimon Glass <sjg@chromium.org>
Wed, 8 Mar 2023 19:40:57 +0000 (11:40 -0800)
The address returned from 'fdt get addr' command must be mapped
into sysmem, as this is a working FDT. Access to this address
without mapping it would lead to crash e.g. in sandbox.

The following command triggers the crash:
"
./u-boot -Dc 'fdt addr $fdtcontroladdr ; fdt get addr var / compatible ; md $var'
"

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/fdt.c

index bc19303159d4ed1c31c05b264d93e13561845737..f2576ab4b388e294b11fbef3193beed3f2fa9df4 100644 (file)
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -468,7 +468,8 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                                        /* Get address */
                                        char buf[19];
 
-                                       snprintf(buf, sizeof(buf), "0x%p", nodep);
+                                       snprintf(buf, sizeof(buf), "0x%lx",
+                                                (ulong)map_to_sysmem(nodep));
                                        env_set(var, buf);
                                } else if (subcmd[0] == 's') {
                                        /* Get size */