[PATCH v3 03/12] libfdt: Detected out-of-space with fdt_finish()

Simon Glass sjg at chromium.org
Tue Sep 1 13:13:56 CEST 2020


At present the Python sequential-write interface can produce an error when
it calls fdt_finish(), since this needs to add a terminating tag to the
end of the struct section.

Fix this by automatically expanding the buffer if needed.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 scripts/dtc/pylibfdt/libfdt.i_shipped | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped
index fae0b27d7d0..1d69ad38e2e 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -786,7 +786,8 @@ class FdtSw(FdtRo):
             Fdt object allowing access to the newly created device tree
         """
         fdtsw = bytearray(self._fdt)
-        check_err(fdt_finish(fdtsw))
+        while self.check_space(fdt_finish(fdtsw)):
+            fdtsw = bytearray(self._fdt)
         return Fdt(fdtsw)
 
     def check_space(self, val):
-- 
2.28.0.402.g5ffc5be6b7-goog



More information about the U-Boot mailing list