Skip to content

Commit

Permalink
libfdt: Add support for disabling internal checks
Browse files Browse the repository at this point in the history
If libfdt returns -FDT_ERR_INTERNAL that generally indicates a bug in the
library. Add a new assumption for these cases since it should be save to
disable these checks regardless of the input.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20200302190255.51426-3-sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
sjg20 authored and dgibson committed Mar 2, 2020
1 parent 28fd759 commit e5cc26b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libfdt/fdt_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ static const struct fdt_property *fdt_get_property_namelen_(const void *fdt,
const struct fdt_property *prop;

prop = fdt_get_property_by_offset_(fdt, offset, lenp);
if (!can_assume(VALID_DTB) && !prop) {
if (!can_assume(LIBFDT_FLAWLESS) && !prop) {
offset = -FDT_ERR_INTERNAL;
break;
}
Expand Down Expand Up @@ -634,7 +634,7 @@ int fdt_node_depth(const void *fdt, int nodeoffset)

err = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth);
if (err)
return (can_assume(VALID_INPUT) || err < 0) ? err :
return (can_assume(LIBFDT_FLAWLESS) || err < 0) ? err :
-FDT_ERR_INTERNAL;
return nodedepth;
}
Expand Down
9 changes: 9 additions & 0 deletions libfdt/libfdt_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ enum {
* device tree is correctly ordered. See fdt_blocks_misordered_().
*/
ASSUME_LIBFDT_ORDER = 1 << 4,

/*
* This assumes that libfdt itself does not have any internal bugs. It
* drops certain checks that should never be needed unless libfdt has an
* undiscovered bug.
*
* This can generally be considered safe to enable.
*/
ASSUME_LIBFDT_FLAWLESS = 1 << 5,
};

/**
Expand Down

0 comments on commit e5cc26b

Please sign in to comment.