libfdt: Improve sequential write state checking

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@gibson.dropbear.id.au>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
David Gibson 2018-04-10 17:06:18 +10:00
parent 04b5b4062c
commit 899d6fad93
5 changed files with 218 additions and 15 deletions

View file

@ -11,7 +11,7 @@ LIB_TESTS_L = get_mem_rsv \
addr_size_cells \
stringlist \
setprop_inplace nop_property nop_node \
sw_tree1 \
sw_tree1 sw_states \
move_and_save mangle-layout nopulate \
open_pack rw_tree1 set_name setprop del_property del_node \
appendprop1 appendprop2 propname_escapes \