fdt_num_mem_rsv() can return an error if the memory reservation block
is not properly terminated with a (0, 0) entry. However several other
places in libfdt called it without checking for error returns, and could
therefore return strange results, or in the case of fdt_open_into()
crash.
Fix this by always checking the return value. Add some addition tests to
catch this bug.
Reported-by: Moshe Strauss <moshestrauss10@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>