Merge branch '2020-06-15-misc-bugfixes'
[platform/kernel/u-boot.git] / lib / optee / optee.c
index d4355c6..457d4cc 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <image.h>
+#include <log.h>
 #include <malloc.h>
 #include <linux/libfdt.h>
 #include <tee/optee.h>
@@ -155,8 +156,9 @@ int optee_copy_fdt_nodes(const void *old_blob, void *new_blob)
        /* optee inserts its memory regions as reserved-memory nodes */
        nodeoffset = fdt_subnode_offset(old_blob, 0, "reserved-memory");
        if (nodeoffset >= 0) {
-               subnode = fdt_first_subnode(old_blob, nodeoffset);
-               while (subnode >= 0) {
+               for (subnode = fdt_first_subnode(old_blob, nodeoffset);
+                    subnode >= 0;
+                    subnode = fdt_next_subnode(old_blob, subnode)) {
                        const char *name = fdt_get_name(old_blob,
                                                        subnode, NULL);
                        if (!name)
@@ -196,8 +198,6 @@ int optee_copy_fdt_nodes(const void *old_blob, void *new_blob)
                                if (ret < 0)
                                        return ret;
                        }
-
-                       subnode = fdt_next_subnode(old_blob, subnode);
                }
        }