[PATCH 3/3] libfdt: fdt_get_name: Add can_assume(VALID_DTB) check
Tom Rini <[email protected]> Tue, 9 Dec 2025 15:50:53 -0600
| Newsgroups | org.kernel.vger.devicetree-compiler |
|---|---|
| Message-ID | <[email protected]> |
In this function from fdt_ro.c we have (reasonably) some checks of the DTB before we begin work. However, we do this in a way that we cannot make use of the normal FDT_RO_PROBE macro and instead have a direct call to fdt_ro_probe_(). Add a test for !can_assume(VALID_DTB) here first so that in cases where we are assuming a valid DTB we can omit the checks. Signed-off-by: Tom Rini <[email protected]> --- This is another case which we see in U-Boot SPL, and for the last 6 years now have had the equivalent check. This change ends up being a noticeable size win for us. --- libfdt/fdt_ro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index b78c4e48f1cb..63494fb7ad90 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -306,8 +306,8 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) const char *nameptr; int err; - if (((err = fdt_ro_probe_(fdt)) < 0) - || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) + if (!can_assume(VALID_DTB) && (((err = fdt_ro_probe_(fdt)) < 0) + || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0))) goto fail; nameptr = nh->name; -- 2.43.0