Browse Source

libfdt: Don't mask fdt_get_name() returned error

Return the error code from fdt_get_name() (contained in len when the
result is NULL) instead of masking it with FDT_ERR_BADSTRUCTURE.

Fixes: fda71da26e ("libfdt: Handle failed get_name() on BEGIN_NODE")
Reported-by: Mike McTernan <mikemcternan@google.com>
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Message-Id: <20220729130019.804288-1-ptosi@google.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Pierre-Clément Tosi 2 years ago committed by David Gibson
parent
commit
50454658f2
  1. 5
      libfdt/fdt_check.c

5
libfdt/fdt_check.c

@ -66,7 +66,10 @@ int fdt_check_full(const void *fdt, size_t bufsize) @@ -66,7 +66,10 @@ int fdt_check_full(const void *fdt, size_t bufsize)
int len;

name = fdt_get_name(fdt, offset, &len);
if (!name || *name || len)
if (!name)
return len;

if (*name || len)
return -FDT_ERR_BADSTRUCTURE;
}
break;

Loading…
Cancel
Save