aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEtienne Carriere2020-06-05 09:22:11 +0200
committerTom Rini2020-06-15 11:23:40 -0400
commit05f0c746069fc950243c108ac90bc1a221c903c5 (patch)
tree988d57c7f39d094d22de6f64bee26128dafc2a44 /lib
parent07672c478e3a6aa0ac2ddb5b05a181b1025fd759 (diff)
optee: fix copy of optee reserved-memory node
Fix the loop that parses FDT for a reserved memory node named "optee". Before this change, if at least one subnode was found in the reserved-memory node, the function endlessly looped since instruction continue returned back in the loop without updating variable subnode. This change fixes the issue by using a for loop. Fixes: 6ccb05eae01b ("image: fdt: copy possible optee nodes to a loaded devicetree") Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/optee/optee.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/optee/optee.c b/lib/optee/optee.c
index e59b5766e72..457d4cca8a0 100644
--- a/lib/optee/optee.c
+++ b/lib/optee/optee.c
@@ -156,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)
@@ -197,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);
}
}