On 11 April 2018 at 22:52, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> wrote: > When creating a tree with the sequential write functions, certain things > have to be done in a certain order. You must create the memory reserve map > and only then can you create the actual tree structure. > > The -FDT_ERR_BADSTATE return code is for if you try to do things out of > order. However, we weren't checking that very thoroughly, so it was > possible to generate a corrupted blob if, for example, you started calling > fdt_begin_node() etc. before calling fdt_finish_reservemap(). > > This makes the state checking more thorough disallow that. > > Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> > --- > libfdt/fdt_sw.c | 89 ++++++++++++++++++++++++++------ > tests/.gitignore | 1 + > tests/Makefile.tests | 2 +- > tests/run_tests.sh | 1 + > tests/sw_states.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 5 files changed, 218 insertions(+), 15 deletions(-) > create mode 100644 tests/sw_states.c Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html