Re: [PATCH v2 01/10] pylibfdt: Fix FdtSw.as_fdt() when buffer is nearly full
From: Simon Glass
Date: Fri Oct 30 2026 - 08:50:31 EST
On 2026-10-28T21:46:49, Douglas Anderson <dianders@xxxxxxxxxxxx> wrote:
> pylibfdt: Fix FdtSw.as_fdt() when buffer is nearly full
>
> `FdtSw.as_fdt()` calls `fdt_finish()` on a copy of `self._fdt` without
> using `self.check_space()`. Because `fdt_finish()` appends the 4-byte
> `FDT_END` token, `as_fdt()` raises `FdtException(FDT_ERR_NOSPACE)` if
> fewer than 4 bytes of free space remain in `self._fdt` after the final
> `end_node()`.
>
> Wrap `fdt_finish()` in a `while self.check_space(fdt_finish(fdtsw)):`
> loop so `FdtSw.as_fdt()` automatically resizes the buffer when needed,
> matching the rest of `FdtSw`'s methods.
>
> Assisted-by: Gemini:gemini-pro-prerelease
> Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
>
> pylibfdt/libfdt.i | 3 ++-
> tests/pylibfdt_tests.py | 8 ++++++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx>