From fcee4a432d79c473809df5db683be2b2df8e8589 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Mon, 21 Dec 2020 12:48:01 -0800 Subject: libfdt: overlay_rename_fragments: handle no fragments in base dtb In case where base dtbo has no fragments, count_fragments returns -FDT_ERR_NOTFOUND. In this case, there is no need to rename fragments in the merged dtbo. Change-Id: Id21c5a4c582b5b16059dae5c954c451a29a49240 Signed-off-by: Elliot Berman --- libfdt/fdt_overlay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c index a5ece6d..2879b04 100644 --- a/libfdt/fdt_overlay.c +++ b/libfdt/fdt_overlay.c @@ -1405,7 +1405,6 @@ next_node: offset = fdt_next_subnode(fdt, offset); } - if (!found) return -FDT_ERR_NOTFOUND; @@ -1428,7 +1427,10 @@ static int overlay_rename_fragments(void *fdt, void *fdto) unsigned long max_base_fragments = 0; ret = count_fragments(fdt, &max_base_fragments); - if (ret < 0) + /* no fragments in base dtb? then nothing to rename */ + if (ret == -FDT_ERR_NOTFOUND) + return 0; + else if (ret < 0) return ret; max_base_fragments += 1; -- cgit v1.2.3-59-g8ed1b