libfdt: overlay: Check the value of the right variable

overlay_update_local_node_references() saves the result of
fdt_subnode_offset() into variable tree_child but checks for variable
ret afterwards. As this does not make sense, check tree_child instead of

This bug has been found by compiling with clang. The compiler reported
the following warning:

    libfdt/fdt_overlay.c:275:7: error: variable 'ret' may be
    uninitialized when used here
                    if (ret == -FDT_ERR_NOTFOUND)
    libfdt/fdt_overlay.c:210:9: note: initialize the variable 'ret' to
    silence this
            int ret;
                    = 0

Signed-off-by: Nicolas Iooss <>
Signed-off-by: David Gibson <>
diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
index 9d03221..ceb9687 100644
--- a/libfdt/fdt_overlay.c
+++ b/libfdt/fdt_overlay.c
@@ -271,7 +271,7 @@
 		tree_child = fdt_subnode_offset(fdto, tree_node,
-		if (ret == -FDT_ERR_NOTFOUND)
+		if (tree_child == -FDT_ERR_NOTFOUND)
 		if (tree_child < 0)
 			return tree_child;