summaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-06 10:27:30 -0600
committerSimon Glass <sjg@chromium.org>2018-07-09 09:11:00 -0600
commitb9066ffc136afd2e46e8d033c4edce98f5557afc (patch)
treec844c67822e6a8d9168a305d6186e51d52fde0a3 /tools/dtoc/fdt.py
parentf9b88b3a5d7ff18760c2c5a0cb596ec8c577706e (diff)
dtoc: Fix Fdt.GetNode() to handle a missing node
At present the algortihm is not correct since it will return the root node if the requested node is not found and there are no slashes in the requested node name. Fix this and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt.py')
-rw-r--r--tools/dtoc/fdt.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 274c142e7a..c1d04d48e8 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -318,7 +318,10 @@ class Fdt:
Node object, or None if not found
"""
node = self._root
- for part in path.split('/')[1:]:
+ parts = path.split('/')
+ if len(parts) < 2:
+ return None
+ for part in parts[1:]:
node = node._FindNode(part)
if not node:
return None