Trying to read a device-tree from an illegal address leads to a crash. Check that the parameter passed to 'fdt addr' is within the RAM area and non-zero.
Signed-off-by: Heinrich Schuchardt <heinrich.schucha...@canonical.com> --- cmd/fdt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/fdt.c b/cmd/fdt.c index 331564c13b..dc954ea7d5 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -193,6 +193,11 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } addr = hextoul(argv[0], NULL); + if (!addr || addr < gd->ram_base || addr >= gd->ram_top) { + printf("Invalid address\n"); + return CMD_RET_FAILURE; + } + blob = map_sysmem(addr, 0); if ((quiet && fdt_check_header(blob)) || (!quiet && !fdt_valid(&blob))) -- 2.40.1