Browse Source

libfdt: Use VALID_INPUT for FDT_ERR_BADSTATE checks

This error indicates a logic bug in the code calling libfdt, so VALID_DTB
is not really the right check. Update it to use VALID_INPUT instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20200302190255.51426-4-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Simon Glass 5 years ago committed by David Gibson
parent
commit
e5c92a4780
  1. 2
      libfdt/fdt.c
  2. 7
      libfdt/fdt_sw.c

2
libfdt/fdt.c

@ -33,7 +33,7 @@ int32_t fdt_ro_probe_(const void *fdt)
} }
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) { } else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
/* Unfinished sequential-write blob */ /* Unfinished sequential-write blob */
if (fdt_size_dt_struct(fdt) == 0) if (!can_assume(VALID_INPUT) && fdt_size_dt_struct(fdt) == 0)
return -FDT_ERR_BADSTATE; return -FDT_ERR_BADSTATE;
} else { } else {
return -FDT_ERR_BADMAGIC; return -FDT_ERR_BADMAGIC;

7
libfdt/fdt_sw.c

@ -12,7 +12,7 @@


static int fdt_sw_probe_(void *fdt) static int fdt_sw_probe_(void *fdt)
{ {
if (!can_assume(VALID_DTB)) { if (!can_assume(VALID_INPUT)) {
if (fdt_magic(fdt) == FDT_MAGIC) if (fdt_magic(fdt) == FDT_MAGIC)
return -FDT_ERR_BADSTATE; return -FDT_ERR_BADSTATE;
else if (fdt_magic(fdt) != FDT_SW_MAGIC) else if (fdt_magic(fdt) != FDT_SW_MAGIC)
@ -41,7 +41,7 @@ static int fdt_sw_probe_memrsv_(void *fdt)
if (err) if (err)
return err; return err;


if (!can_assume(VALID_DTB) && fdt_off_dt_strings(fdt) != 0) if (!can_assume(VALID_INPUT) && fdt_off_dt_strings(fdt) != 0)
return -FDT_ERR_BADSTATE; return -FDT_ERR_BADSTATE;
return 0; return 0;
} }
@ -67,7 +67,8 @@ static int fdt_sw_probe_struct_(void *fdt)
if (err) if (err)
return err; return err;


if (fdt_off_dt_strings(fdt) != fdt_totalsize(fdt)) if (!can_assume(VALID_INPUT) &&
fdt_off_dt_strings(fdt) != fdt_totalsize(fdt))
return -FDT_ERR_BADSTATE; return -FDT_ERR_BADSTATE;
return 0; return 0;
} }

Loading…
Cancel
Save