There is a use after free in kwbimage, found by building u-boot with the
use after free detection enabled in malloc. When building the clearfog target:
MKIMAGE u-boot-spl.kwb
Segmentation fault (core dumped)
kwbimage_generate -> image_version_file (alloc and free image_cfg global)
kwbimage_generate -> image_headersz_v1 -> image_count_options (image_cfg used)
It isn't clear to me if image_version_file should be inlined or another
approach taken, but as it stands it is clearly wrong.
The result of image_version_file is also never checked for -1 which multiple
paths in the function return.
I reported this on the u-boot list a week or so ago but no one has responded
so far.