Hi Alexey,
On 2026-09-18T10:52:27, Alexey Charkov <[email protected]> wrote:
> test: spl: Keep the payload create_fit() is handed
>
> fdt_create() clears the whole buffer it is given, and for a FIT with
> internal data that buffer covers the payload the caller has already
> written at the offset create_image() told it to use. So every
> FIT_INTERNAL test has been loading zeros and comparing them against the
> same zeroed memory, and would pass whatever the loader did with them.
Nice catch!
Since this fixes a bug in the test, please can you add a tag:
Fixes: b93cc1e73e1 ("test: spl: Add functions to create images")
>
> Keep a copy of the payload across the call.
>
> Signed-off-by: Alexey Charkov <[email protected]>
>
> test/image/spl_load.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
> diff --git a/test/image/spl_load.c b/test/image/spl_load.c
> @@ -184,8 +185,28 @@ static size_t create_fit(void *dst, struct
> spl_image_info *spl_image,
> + if (payload) {
> + memcpy(dst + off, payload, spl_image->size);
> + free(payload);
> + }
This fixes the problem, but nothing stops it coming back, since the
callers compare the loaded data against the same buffer which
create_fit() can clobber. It went unnoticed because both sides of
ut_asserteq_mem() ended up as zeroes.
I suspect it is worth adding a check in the callers, e.g. in
spl_test_image() and do_spl_test_load(), that the payload in the image
is still what generate_data() produces after create_image() returns.
Even just regenerating the data into a separate buffer and comparing
against that would do. What do you think?
Regards,
Simon